是中文成了乱码了吗?
你的jsp里是不是用的charset = gb2312?
如果是的话,存之前先转换一下:
byte[] temp = string.getBytes("ISO8859-1");
String s = new String(temp);
再存s
试一下:)

解决方案 »

  1.   

    或者这样:希望得到字串=new String(目标字串.getByte("gb2312"),"ISO-8859-1")
      

  2.   

    存之前先转换一下:
    String s = new String(aaa.getBytes("8859-1"))
      

  3.   

    是中文转换问题,必须将8859码装化为GB2312
    string namestr=request.getParameter("name");
    String name=ndw String(namestr.getBytes("8859_1"),"gb2312");
    out.println(name);   <-------name 已经转化为中文
      

  4.   

    好像mysql对中文的支持比较好,
    从另一个页面传来的中文字符,不做转码写入mysql,mysql中的数据就已经是中文的拉
    若坐了转码,反而会得到????
      

  5.   

    试试在你的jsp页看看你的web服务器是什么编码的:
    String lEnc = request.getCharacterEncoding();
    out.println("Encoding = "+lEnc);如果返回null的话,则需要在一开始设置编码,如下:
    <%
    request.setCharacterEncoding("GBK");//或者用GB2312编码;
    %>如果不为null的话,则要做一下转换:
    存入数据库的字符 = new String(原来字符.getBytes(lEnc), "GBK");
    //或者用GB2312代替GBK再试试看。
      

  6.   

    各位大侠,以上方法都试过了,jsp试用gb2312编码的,url也设了,字符也进行过以上的转换,但是都不灵,我用的试mysql4.0和mysql-connector-java-3.0.8-stable连接的,当我用mm.mysql.jdbc-1.2c连接jsp和mysql时就不会有乱码,但是mm.mysql.jdbc-1.2c不能用jdbc中的rs.last()等函数,也就不能进行分页(可能有其他方法,我不晓得),那位知道原因可否告知,急啊[email protected]先谢过了,如有知道mm.mysql.jdbc-1.2c连接时怎么分页请告知
      

  7.   

    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;  
     }  
       }
      

  8.   

    用它肯定没问题。
    <%@ page import="aaa.bbb.ccc.*" contentType="text/html;charset=gb2312"%>String name=new String(request.getParameter("name").getBytes("8859_1"));
      

  9.   

    哎,也不可以阿,快疯掉了,是不是Connector/J 3.0不支持中文啊,要不怎么会怎么转换都不可以呢,
    有用过jsp+mysql用Connector/J 3.0连接可以存入中文的嘛?
    怎么会这样那
    用mm.mysql.jdbc-1.2c可以存中文啊哎呀
    愁死了