你应该在每个jsp程序前面加上
<%@page contentType="text/html; charset=gb2312"%>或者
<%@page contentType="text/html; charset=GBK"%>
这是必须的。
否则肯定出问题!

解决方案 »

  1.   

    happylcq1120说的我已经做过了,这是仍没用
      

  2.   

    你SQL Server的字符集有问题,检查一下!
      

  3.   

    做一个bean来转码!在一个page中每个关于数据库字段的地方用它,编码方式可以灵活设置!
    import java.io.*;public class contcode
    {
        public String descode = "";
        public String srccode = "";
        public String getnewcode(String sourcestr)
        {
         String tmp;
         try
         {
         if(srccode.equals("") && descode.equals(""))
    {tmp = sourcestr;}
         else if(srccode.equals(""))
         {tmp = new String(sourcestr.getBytes(),this.descode);}
         else
         {tmp = new String(sourcestr.getBytes(this.srccode),this.descode);}
         }
         catch(Exception e)
         {
          tmp = this.descode + "->>" + this.srccode;
         }
            return(tmp);
        }
        
        public String getnewcode(String sourcestr,String scode,String dcode)
        {
         String tmp;
         try
         {
         if(scode.equals("") && dcode.equals(""))
    {tmp = sourcestr;}
         else if(scode.equals(""))
         {tmp = new String(sourcestr.getBytes(),dcode);}
         else
         {tmp = new String(sourcestr.getBytes(scode),dcode);}
         }
         catch(Exception e)
         {
          tmp = dcode + "->>" + scode;
         }
           return(tmp);
        }}
      

  4.   

    在数据库中把字段设为nvarchar型,这个没问题
      

  5.   

    你将中文在转回来试一下。  str=new String(str.getBytes("8859_1")); //str是变量名
      

  6.   

    对,引用别人的解决方法:
    如果数据库中中文正确,文件头上加:
    <%@ page contentType="text/html;charset=gb2312" %>
    就可以了
    如果数据库中的不正确就要在写进数据库前用String str=new String(str.getBytes("ISO8859_1"),"gb2312")转换一下