doGetとdoPostの中国語の文字化けしの問題を解決します


request中国語文字化けし問題!!!
request中国語の文字化けし問題を解決するには、getリクエストとpostリクエストの2つの状況に分けます.
1.get
//       iso      ,    。  Tomcat       iso8859-1  
 
String username = request.getParameter("username");
 
//    ISO   ,      ,      ,    U8       
 
byte [] bytes = username .getBytes("ISO-8859-1");
 
username = new String(bytes, "utf-8");

2.post
//   Post         ,    ,       。
 
//                 ,  get       ,        get  。
request.setCharacterEncoding("UTF-8");

終わりだ!