1.如果是Servlet write时中文乱码,就添加下面三行代码:
response.setHeader("Content-type","text/html;charset=UTF-8");//告诉浏览器编码体式格式;
response.setContentType("text/html;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
2.如果是在Servlet中有输出下载地址,并且href中有中文,那么就得在Tomcat的server.xml中添加URIEncoding="UTF-8"就可以解决问题
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>