1.设置字符集编码
String rolename2 =
new String(rolename.getBytes("iso-8859-1"),"gb2312");
2.修改Tomcat中的Server.xml文件,
<Connector port="8080"
protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
3.设置编码格式一定是在流产生之前设置
response.setContentType("application/json;charset=GBK");
PrintWriter pr=response.getWriter();