进行以下编码就可以了
String s=request.getParameter("name");
s=new String(s.getBytes("ISO8859_1"),"gb2312");

解决方案 »

  1.   

    方法一:<%@page contentType="text/html; charset=GBK"%> 方法二:String s="总类管理";
    byte[] sbyte=s.getBytes("ISO8859_1");
    s=new String(sbyte);或者strvalue = new String(strvalue.getBytes("ISO8859_1"), "GBK"); 例:public static String UnicodeToChinese(String s){
      try{
         if(s==null||s.equals("")) return "";
         String newstring=null;
         newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
         return newstring;
        }
      catch(UnsupportedEncodingException e)
      {
      return s;
      }
      }public static String ChineseToUnicode(String s){
      try{
      if(s==null||s.equals("")) return "";
      String newstring=null;
      newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
       return newstring;
      }
      catch(UnsupportedEncodingException e)
      {
      return s;
     }
     }
      

  2.   

    String mAdType=new String(request.getParameter("mAdType").getBytes("iso-8859-1"));
      

  3.   

    在Servlet里直接out.print,出现乱码的话,content type 设为 GBK,就没问题了.
    从JSP的FORM中提取的汉字出现乱码的话, content type 设为ISO8859_1,就没问题了.这两个是个矛盾,因此我解决的办法就是
    (1) content type设为ISO8859_1
    (2) 在Servlet的out.print尽量不用中文.
    (3) 如果必须用中文,则自已写个bean,里面设一些静态的中文字符串,需要的时候直接调用.