Javaweb前后台传中文出现乱码问题

来源:互联网 发布:openwrt 网络重启命令 编辑:程序博客网 时间:2024/06/08 03:06

Ajax传后台:

           AJAX:

                    postdata= encodeURI(encodeURI("InsRootPath=" + getimageRoot() +"));//两层封装

        后台解析:

                    String rootPath = request.getParameter("InsRootPath");
    rootPath = URLDecoder.decode(rootPath, "UTF-8"); 



后台传到Ajax: 

             注意设置:

                        response.setHeader("Content-type", "text/html;charset=UTF-8");  
 
response.getWriter().println(str1);

原创粉丝点击