目录

PrintWriter Web页面乱码

一般情况只使用下面代码:

1
2
PrintWriter out = response.getWriter()
out.print("爱死费崇政");

输出到页面上基本会呈现出乱码现象,解决方案如下:

1
2
3
4
response.setCharacterEncoding("utf-8");       
response.setContentType("text/html; charset=utf-8");
PrintWriter out = response.getWriter()
out.print("爱死费崇政");