Tomcat8.x下的get方法中文乱码问题

来源:互联网 发布:mac软件 编辑:程序博客网 时间:2024/05/16 04:45

在Tomcat7.x下的没有中文乱码:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {        response.setContentType("text/html;charset=utf-8");        String name = request.getParameter("name");        name = new String(name.getBytes("IS0-8859-1"),"utf-8");}

在8.x下会出现问号的问题
解决方法:

new String(name.getBytes(),"utf-8");
原创粉丝点击