PrintWriter 乱码问题

response.setContentType("application/json; charset=UTF-8");
PrintWriter out = response.getWriter();

此处需要注意 setContentType() 必须写在response.getWriter() 之前才起作用;

2、检查tomcat 中server.xml 中配置

 URIEncoding="utf-8" useBodyEncodingForURI='true' connectionTimeout="20000" port="8300" protocol="HTTP/1.1" redirectPort="8444"/>
URIEncoding是修改tomcat 编码 useBodyEncodingForURI是为了GET与POST的编码一致

你可能感兴趣的:(PrintWriter 乱码问题)