response.setCharacterEncoding(“utf-8”);
当我们在使用字符流写入数据的时候,修改Response容器的编码
response.setHeader(“content-type”, “text/html;charset=utf-8”);
告诉浏览器以utf-8码表去显示数据
response.setContentType(“text/html;charset=utf-8”);
这一行代码就相当于上面的两行代码的效果,因为在setContentType方法中已经调用了setCharacterEncoding方法设置了Response容器的编码

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐