1.直接调用jsp页面时显示乱码
在jsp页面的开始添加<%@ .....pageEncoding="UTF-8"%>
2.直接调用servlet打印文字时
在打印前加上response.setContentType("text/html;charset=utf-8");
如果还有乱码则在servlet中加上String s = new String(a.getBytes("iso-8859-1"),"utf-8");
3.post表单传递参数乱码
servlet在接收参数之前,使用request.setCharacterEncoding("utf-8");
4.URI方式传递参数乱码(get方式)
在server.xml中找到<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" / >后面加上属性URIEncoding="uft-8"