servlet中文亂碼問題

ml_zhu 12年前發布 | 42K 次閱讀 亂碼 Servlet Java開發 JSP
1、post方式解決方案:
         request.setCharacterEncoding("utf-8");
     response.setCharacterEncoding( "utf-8" );

2、get方式
       String string = request。getParamers("");
        String = new String(string.getBytes("ISO8859-1","utf-8"));

3、修改tomcat的server.xml
          <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000"
               redirectPort="8443" URIEncoding="utf-8"  />

4、修改tomcat的server.xml
          <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" useBodyEncodingForURI="true"  />
 
5、超鏈接也是get方式
 本文由用戶 ml_zhu 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!