Servlet乱码问题解决
-
使用String重新进行编码
String name = new String(name.getBytes("ios-8859-1"),"utf-8")
-
get请求乱码
request.setCharacterEncoding("utf-8");
在server.xml中添加属性useBodyEncodingorURI=true
-
post请求乱码
request.setCharacterEncoding("utf-8");
-
response乱码
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8")