不要用GBK,用gb2312,如:
<%@ page contentType="text/html;charset=gb2312"%>

解决方案 »

  1.   

    <%@ page contentType="text/html;charset=gb2312"%>这句话对直接写在页面中的中文有效,对从数据库中取出的中文数据就无效了。试试下面的代码吧:<% out.print(new String(rs.getString("title").getBytes("ISO8859_1"),"GB2312")); %>其中rs.getString("title")可以替换成你的代码,在我的IIS+Resin2.1.8+mysql上测试通过。
      

  2.   

    不行啊,仍然是直接写在页面中的中文正常,
    从数据库中取出的中文数据显示为乱码。:-(
    我用的是tomcat4+apache2+access
      

  3.   

    和你数据库的设置有关,如果你的数据库也是GBK的,页面charset也是GBK,那就没问题。
      

  4.   

    送你这个类
    package com.windy.util;/**
     * <p>Title: </p>
     * <p>Description:  </p>
     * <p>Copyright: Copyright (c) 2003</p>
     * <p>Company: </p>
     * @author Windy
     * @version 1.0
     */
    import java.io.*;public class L18NString {  private static final String  inCode   = "ISO-8859-1";      //数据库的编码方式
      private static final String  outCode  = "";                //页面编码方式。默认系统编码。  /**
       * 空构造。
       */
      private L18NString() {
      }  /**
       * 从数据库读取字符串返回到页面时
       * @param inputString
       * @return
       */
      public static String readString(String inputString){
        try {
          byte[] tempByte = inputString.getBytes(inCode);
          inputString = new String(tempByte,outCode);
        }
        catch (UnsupportedEncodingException ex) {
          throw new RuntimeException("Unsupported encoding type.");
        }finally{
          return inputString;
        }
      }  /**
       * 从页面接收字符串插入到数据库时
       * @param inputString
       * @return
       */
      public static String writeString(String inputString){
        try {
          byte[] tempByte = inputString.getBytes(outCode);
          inputString = new String(tempByte,inCode);
        }
        catch (UnsupportedEncodingException ex) {
          throw new RuntimeException("Unsupported encoding type.");
        }finally{
          return inputString;
        }
      }  public static void main(String[] args){
      }
    }
      

  5.   

    转换函数
         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;
            }
        }
      

  6.   


      打印出从数据库返回的String的内码看看。再决定是否需要转换。