你最好是自己写一个中文转换的方法,特别是在从数据库中读出中文的时候。向数据库写信息的时候好象可以不转换的。
public String getStr(String str)
{
  if(str==null) {
   str="";
}
  String temp="";
  try
  {
  byte[] temp_t=str.getBytes("ISO-8859-1");
  temp=new String(temp_t,"Big5");
  str=temp;
  }
  catch(Exception e)
  {
  System.out.println("iso8859-1 error"+e);
  return null;
  }
  return str;
}

解决方案 »

  1.   

    你是什么乱码啊?是插入数据库乱还是读出乱啊?你先去看一下/etc/profile。命令:vi /etc/profile
    加入:export LANG=zh
    注意大小写哈。试试再说
      

  2.   


    你把所有的编码采用 gb2312 方式处理jsp 页面:<%@ page contentType="text/html; charset=gb2312" %>
    <%request.setCharacterEncoding("gb2312");%>
      

  3.   

    一楼的,你写错一行关键代码了,应该是:
      byte[] temp_t=str.getBytes("ISO-8859-1");
      temp=new String(temp_t);或temp=new String(temp_t,"GB2312");
      

  4.   

    入库之前改变下编码就好了,直接对sql语句编码就成
    sql=new String(sql.getBytes(),"8859_1");1.s=new String(s.getBytes(),"iso-8859-1");
    2.s=new String(s.getBytes(),"gb2312");
    3.s=new String(s.getBytes("iso-8859-1"),"gb2312");
    4.s=new String(s.getBytes("gb2312"),"iso-8859-1");
    5.s=new String(s.getBytes("iso-8859-1"));
    6.s=new String(s.getBytes("gb2312"));
    尝试以上的方法之一!
    页面中添加如下代码:
    <%@ page contentType="text/html;charset=gb2312" %>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
      

  5.   

    我现在能从数据库中取到中文,
    我的页面启用了<%@ page contentType='text/html; charset=GB2312' %>
    这样可以使从后台来的数据以GB2312显示
    还有一点当我 把后台来的数据人工转成GB2312显示出现乱码
    转码代码:
    private  String codeString(String s){
       String str=s;
       String temp="";    try{
          byte[] temp_t=str.getBytes("ISO-8859-1");
        temp=new String(temp_t,"GB2312");
        log.info("codeString = " + str);
    return temp;
      }
    catch(Exception e)
     {
      log.error("e codeString = " + str);
       return temp;
     }
       } 我怀疑orcle 数据库不是:ISO-8859-1
    我怎样知道orcle 数据库的编码