码迷,mamicode.com
首页 > 其他好文 > 详细

乱码问题

时间:2018-01-28 19:09:21      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:encoding   ring   server   https   tps   throw   ack   htm   ret   

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;
            }
        }

乱码问题

标签:encoding   ring   server   https   tps   throw   ack   htm   ret   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!