java之乱码
java常见乱码
1.request.getCharacterEncoding("utf-8");
2.new String(username.getBytes("iso-8859-1","utf-8"))
3.tomcat默认情况下只适合post传值
在server.xml中找到Connector标签 添加一个属性useBodyEncodingForUrl="true"或者URIEncoding="utf-8";
4.数据库与表设置
5.响应乱码
response.setContextType("text/html");
response.setCharacterEncoding("utf-8");
6.连接字符串编码设置
jdbc:mysql://localhost:3306/album?characterEncoding=utf-8