关于中文 问题是个常 见问题。
不知你是怎么做的。一般而言只要在每个JSP页面有这句:
<%@ page contentType="text/html;charset=gb2312" %>
另外在数据库配置文件中有个转化为中文 的函数toChinese()
当然可以是别的名字中有这句:
strvalue = new String(strvalue.getBytes("GBK"), "gb2312");
一般情况下中文 就没什么问题。以上是我的个人以验。
如果还不行就将
strvalue = new String(strvalue.getBytes("GBK"), "gb2312");
换为:
strvalue = new String(strvalue.getBytes("ISO8859-1"), "gb2312");

解决方案 »

  1.   

    奇怪,我把数据从mysql里面读出来的时候没什么问题(当然了要经过一定的处理)
    但是我把数据写进mysql的时候,却出现了问题!
    从mysql数据读出来之前我是这么处理的
      byte[] bytes;
      bytes=rs.getBytes("xxx");
      String str=new String(bytes,"ISO8859-1");
      那么,这个str就是unicode的了!
    麻烦大家帮我解决一下我插入数据时候的问题!
      

  2.   

    我觉得在JSP的页面有这句:
    byte[] temp;
       temp=xm.getBytes("iso-8859-1");
    xm=new String(temp);
    我觉得是这样,如果不对就SORRY!!
      

  3.   

    与你的os和容器有关,你把os和容器说出来才能知道用什么办法。
    因为中文问题没有固定的解决方法,大体上就是两个编码的转换但是这和你的os和容器有很大关系。
      

  4.   

    转换函数
         public static String U2C(String s)
        {
          String str = s;
         try
            {
              if ( str == null ) return str;
              byte[] u = str.getBytes("iso-8859-1");
              return new String(u,"GB2312");
            }
            catch(java.io.UnsupportedEncodingException e)
            {
              e.printStackTrace();
              return str;
            }
        }
      

  5.   

    一般加上这个
    <%@ page contentType="text/html;charset=gb2312" %>
    就可以了
      

  6.   

    javax.servlet.http.HttpResponse类用于产生返回页面.通过HttpResponse定义的方法getOutputStream()可以获得ServletOutputStream的实例,这样用户就可以利用ServletOutputStream.write方法向输出流中写入返回页面的内容. 但是ServletOutputStream使用的是缺省的编码方式,如果要使返回页面中的中文字 符能够正常显示,最好显示地指定所用的字符编码方式. 通常需要构造一个 OutputStreamWriter , 例程如下: 
    public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); ServletOutputStream out = res.getOutputStream(); OutputStreamWriter ow = new OutputStreamWriter(out,"GB2312"); ow.write("这是测试"); ow.flush(); ow.close(); } 
      

  7.   

    你读出时用String str=new String(bytes,"ISO8859-1");
      String zx01Value = "你好";
     写入时也用String temp = new String(zx01Value.getBytes("GBK"),"ISO8859_1");试
      

  8.   

    <%@ page contentType="text/html;charset=iso8859_1"%>
    <%response.setContentType("text/html;charset=iso8859_1");%><meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=GB2312">  //把数据库中取得的结果转化--显示汉字 
      public String GS(String str)
      { try
         { String temp_p=str;
           byte[] temp_t=temp_p.getBytes("GBK");
           String temp=new String(temp_t,"ISO8859_1");
           return temp;
          }
        catch(Exception e) { return "null";} 
      }  //入库前把表单中提交的中文进行转换
      public String toGB(String iso)
      { String gb=null; 
        if (iso != null)
        { try { gb=new String(iso.getBytes("ISO8859_1"),"GB2312"); } 
          catch (Exception e) { gb=null; } 
        } 
        return gb; 
      }
      

  9.   

    你用的是哪个 MySQL JDBC Driver?如果是 [mysql-connector-java-3.0.6-stable-bin.jar] 的话,建立数据库连接如下:Class.forName("com.mysql.jdbc.Driver");
    String url = "jdbc:mysql://localhost/coffeebreak?" +"useUnicode=true&characterEncoding=gb2312";
    con = DriverManager.getConnection (url,"username", "password");