see:http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=29037
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=2334
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=455

解决方案 »

  1.   

    在你得JSP最前面加一句
    <%@ page contentType="text/html; charset=gb2312" %>
      

  2.   

    进行字符转换
    <%request.setCharacterEncoding("gb2312");%>
      

  3.   

    你定义一个METHOD
    加个方法:
    <%!public getStr(String str) throws Exception
      {    
        String temp=str;
        byte[] temp_p=temp.getBytes("ISO-8859-1");
        return new String(temp_p,"GBK");;
       }
    %>
    然后在插入数据库之前将有中文的变量用这个方法将变量转换一下:
    String text=null;
    if(request.getParameter("text")!=null&&request.getParameter("text")!="")
    {
       text=getStr(request.getParameter("text"));
     }
      

  4.   

    你定义一个METHOD
    加个方法:
    <%!public getStr(String str) throws Exception
      {    
        String temp=str;
        byte[] temp_p=temp.getBytes("ISO-8859-1");
        return new String(temp_p,"GBK");;
       }
    %>
    然后在插入数据库之前将有中文的变量用这个方法将变量转换一下:
    String text=null;
    if(request.getParameter("text")!=null&&request.getParameter("text")!="")
    {
       text=getStr(request.getParameter("text"));
     }
      

  5.   

    假如是WEBLOGIC修改一下配置文件就可以了,其他的容器可以利用SERLET2.3的过滤器进行统一处理,小CASE!
      

  6.   

    解决办法:  
    第一:  
     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;  
     }  
       }