HttpServletRequest/HttpServletResponse乱码问题解决

时间:2021-08-09 10:17:04

1、request.setCharacterEncoding只对POST请求起作用。GET请求用new String(paramterData.getBytes("iso8859-1"),"UTF-8");

2、response.setContentType指定HTTP 响应的编码,同时指定了浏览器显示的编码. 等价于response.setCharacterEncoding指定HTTP 响应的编码和response.setHeader("contentType", "text/html; charset=utf-8”)指定了浏览器显示的编码