亂碼問題

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;
            }
        }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章