我用下面的方法转换后存还是乱码
<%!
public String toChinese(String strvalue){
       try{
           if(strvalue==null)
                return null;
           else{
                strvalue=new String(strvalue.getBytes("ISO8859_1"),"GBK");
                return strvalue;
               }
       }catch(Exception e){
                return null;
       }
    }%>
还有什么别的方法吗?我想是不是连接池没有配好
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/feaket?username=root;password=sa;useUnicode=true;characterEncoding=GB2312</value>
</parameter>

解决方案 »

  1.   

    <%!
      public String getStr(String str) {
          try {
              String temp_p = str;
              byte[] temp_t = temp_p.getBytes("ISO8859-1");
              String temp = new String(temp_t);
              return temp;
          } catch(Exception e) {
          }
          return null;
      }
    %>
      

  2.   

    你试试转化或者不转换
    还有转换成其他的码因为可能你的mysql不支持gb2312
    那你就试试utf-8
      

  3.   

    你试试转化或者不转换
    还有转换成其他的码因为可能你的mysql不支持gb2312
    那你就试试utf-8
      

  4.   

    谢谢你的回复还是不行,我决的是连接池问题,不知道useUnicode=true;characterEncoding=GB2312在下面的参数中这样用对不对
    <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost/feaket?username=root;password=sa;useUnicode=true;characterEncoding=GB2312</value>
    </parameter>