首页 > 其他 > 详细

乱码问题

时间:2018-01-28 19:05:28      阅读:191      评论:0      收藏:0      [点我收藏+]
post: 软编码
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");

get:
软编码

    1:修改tomcat
        conf文件夹下~~~》server.xml line69~~~》
        useBodyEncodingForURI="true"

    2:硬编码
        public void doGet(HttpServletRequest request
        ,HttpServletResponse response)throws Exception{
            String name = request.getParameter("key");
            String newName = change(name);
        }

        public String change(String old){
            try{
                return new String(old.getBytes("iso-8859-1"),"utf-8");
            }catch(Exception ex){
                ex.printStackTrace();
                return null;
            }
        }

乱码问题

原文:http://blog.51cto.com/12941821/2066043

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!