响应编码:服务器--->客户端
如:服务端响应response.getWriter().print("大家好");
服务器设置编码:
response.setCharacterEncoding("utf-8") //设置服务器响应编码
客户端设置编码:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
服务端和客户端同时设置编码(一句顶两句:
response.setHeader("Content-Type","text/html;charset=utf-8")
更简便的方法:
response.setContentType("text/html;charset=utf-8");