是不是你在JSP中的中文处理写的有问题呀,
我不太清楚你的意思,那在JSP中看到是什么,
我给你一段中文处理,看你能不能帮上忙
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)
   {
      e.printStackTrace() ;
   }
   return "null";
}

解决方案 »

  1.   

    解决办法:
    第一:
    在jsp页面加入:
    <%@ page contentType="text/html; charset=gb2312" %>
    或者在servlet里面
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html; charset=gb2312");
    上面的如果在不行就用如下的方法在数据入库前进行调用:
    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 content;
    content = new String(content.getBytes("ISO8859_1"),"GB2312");
      

  3.   

    String url = "jdbc:mysql://"+ host + ":3306/db?user=" + usr + "&password=" + pwd + "&useUnicode=true&characterEncoding=GB2312";
    主要是要在连接URL加上这些属性
    useUnicode=true&characterEncoding=GB2312";
      

  4.   

    哦,编码转换一下,这个我知道,我用的是JSP处理写入数据库不是用的servlet写入数据库的,我一会试试你的方法,我记得在 resin 配置文件里有一个加入什么的来的我忘了,改为gb2312,我说的很糊涂,不知道你知道我说的什么意思吗?
      

  5.   

    加这个不好使
    String mysqlURL="jdbc:mysql_caucho://localhost:3306/pic_db&useUnicode=true&characterEncoding=GB2312";
    我把&换成?也不行。出错。编译没错,执行出错。我的环境的是 jsp+resin+mysql
      

  6.   

    public String ChineseStringToAscii(String s){
    try 
    {
    CharToByteConverter toByte = CharToByteConverter.getConverter("gb2312"); 
    byte[] orig = toByte.convertAll(s.toCharArray()); 
    char[] dest = new char[orig.length];
    for (int i=0;i<orig.length;i++)
    dest[i] = (char)(orig[i] & 0xFF); 
    return new String(dest); 
    }
    catch (Exception e) {
    System.out.println(e); 
    return s; 
    }
    }
    先把你要插入数据的sql转为Ascii码就行了,这样在数据库你面看到的是中文
    读出来的时候用一般的String(s.getBytes("ISO8859_1"),"gb2312"); 方法即可