<%@ page contentType="text/html; charset=gb2312"%>
加上这句后只是对当前页面用gb2312字符编码来显示;
而此时数据库中采用的字符编码格式却不是gb2312,从数据库取出后应先转码(比如可先还原成相应字节),再显示(重新用gb2312编码)

解决方案 »

  1.   

    在你的页面中凡是写java代码的开头都加一句 request.setCharacter("GBK");
      

  2.   

    而<%@ page contentType="text/html; charset=gb2312"%>
    只是对当前页面设置编码格式
      

  3.   

    public class Convert{
        
        public static String convertGBtoISO(String str){
            String strr=null;
            try{
            strr=str;
            
            }catch(Exception e){} 
            return strr;        
        }
         public static String convertISOtoGB(String str){
             String strr=null;
                try{
                strr=new String(str.getBytes("gb2312"));
                
                }catch(Exception e){} 
                return strr;  
         }
    }
    进行一次这样的转码就可以了