已经使用全局的编码拦截器,但是使用
PrintWriter out = response.getWriter();
out.println("用户名:"+username);
out.println("密码:"+password);
输出时还是出现了乱码,解决方案是在这几句之前加上
response.setContentType("text/html;charset=utf-8");
亲测可用!
本文介绍了一种常见的网页乱码问题及其解决方案。当使用全局编码拦截器仍然出现乱码时,可以通过设置响应内容类型为UTF-8来解决。具体做法是在输出字符前添加response.setContentType(text/html;charset=utf-8);的代码。
已经使用全局的编码拦截器,但是使用
PrintWriter out = response.getWriter();
out.println("用户名:"+username);
out.println("密码:"+password);
输出时还是出现了乱码,解决方案是在这几句之前加上
response.setContentType("text/html;charset=utf-8");
亲测可用!
6925