这两句代码都是设置字符集为utf-8
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setContentType作用是让浏览器用utf-8来解析返回的数据
response.setCharacterEncoding作用是告诉servlet用utf-8转码,而不是用默认的iso8859-1
参考资料:
这两句代码都是设置字符集为utf-8
response.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setContentType作用是让浏览器用utf-8来解析返回的数据
response.setCharacterEncoding作用是告诉servlet用utf-8转码,而不是用默认的iso8859-1
参考资料: