tomcat中文乱码 get 请求.
修改server.xml中的<Connector></Connector>添加URIEncoding='UTF-8'
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding='UTF-8' />
tomcat中文乱码 post 版
另外HttpURLConnection上传参数的时候要转码成url编码
outStream.writeBytes("&" + URLEncoder.encode(key, "utf-8") + "=" + URLEncoder.encode(value, "utf-8"));
mysql 中文乱码
修改 my.cnf ,在 [mysqld] 下面添加
character-set-server = utf8
创建数据库的时候制定编码格式为 utf-8
CREATE DATABASE dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
或者修改已有数据库/表编码格式为 utf-8
ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
来源:oschina
链接:https://my.oschina.net/u/237198/blog/265959