为什么设置setContextType不起作用?
我将setContextType设置为text/html;charset=UTF-8
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
request.setCharacterEncoding("UTF-8");
String username = request.getParameter("username");
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
out.println(username);
}
但响应头为Content-Type: text/html;charset=ISO-8859-1