Servlet处理乱码问题
作者:互联网
目前Servlet乱码的处理方式主要有两种;
- 推荐使用:response.setHeader("content-type", "text/html;charset=UTF-8");
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setHeader("content-type", "text/html;charset=UTF-8");
Writer writer = response.getWriter();
writer.write("贵阳学院");
}
- write()方法
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String name = "解决乱码问题";
OutputStream out=response.getOutputStream();
out.write(name.getBytes());
}
标签:write,处理,text,writer,HttpServletResponse,乱码,Servlet,response 来源: https://www.cnblogs.com/fengxiaojie/p/16205324.html