解决办法:  
第一:  
 1:在jsp页面加入:  
<%@  page  contentType="text/html;  charset=gb2312"  %>  
 2:在servlet里面:  
   public  void  doGet(HttpServletRequest  request,  HttpServletResponse  response)  throws  ServletException,  IOException  {  
       response.setContentType("text/html;  charset=gb2312");//这是重要的  
 
3:上面的如果在不行就用如下的方法在数据入库前进行调用:  
public  static  String  UnicodeToChinese(String  s){  
   try{  
         if(s==null  &brvbar;  &brvbar;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  &brvbar;  &brvbar;s.equals(""))  return  "";  
   String  newstring=null;  
   newstring=new  String(s.getBytes("gb2312"),"ISO8859_1");  
     return  newstring;  
   }  
   catch(UnsupportedEncodingException  e)  
   {  
   return  s;  
 }  
   }

解决方案 »

  1.   

    第一种方法我试过了,不行。我不是要把它放到数据库中,我是用它来发邮件,发到我的邮箱中,我发现Action中得到的ActionForm中的数据都是乱码,有没有在ActionForm中解决的方法?多谢
      

  2.   

    把楼上的那段代码,放到actionform中试试!!
      

  3.   

    String str = new String((form.getXxx).getBytes("iso-8859-1"),"GB2312");
      

  4.   

    用一个Servlet Filter 来进行转换,将所有的iso8859-1编码转化成gb2312编码就可以了。