设置了response.setContentType("text/html;charset=utf-8");仍然乱码
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
Cookie[] cookies = request.getCookies();//获取所有的Cookie
boolean flag = false;
浏览器打开F12,发现响应头没问题
HTTP/1.1 500
Content-Type: text/html;charset=utf-8
Content-Length: 88
Date: Thu, 10 Nov 2022 11:09:54 GMT
Connection: close
你接受请求的时候应该是request.setCharacterEncoding("utf-8");
响应的应该是response.setContentType("text/html;charset=utf-8");