中文用gb2312
<@page content="text/html charset=gb2312"%>

解决方案 »

  1.   

    用gb2312和uft-8全部是乱码 郁闷
      

  2.   

    试一下db.url=jdbc:mysql://xxxxxxx/xxxxx?useUnicode=true&characterEncoding=gb2312
      

  3.   

    没错,是从数据库读出来的字符集不对,可以在读出后进行字符集设置,然后再显示。但如果是用java去写数据库的话取的时候就不用再设置的。
      

  4.   

    当用JDBC driver向数据库中插入数据时,需要先将Unicode转成native code; 当 JDBC driver从数据库中查询数据时,则需要将native code转换成Unicode. 下面给出了这两种转换的实现: 
    String native2Unicode(String s) { 
     if (s == null || s.length() == 0) { 
       return null; 
     }  byte[] buffer = new byte[s.length()]; 
     for (int i = 0; i s.length(); i++) { 
      if (s.charAt(i)>= 0x100) { 
        c = s.charAt(i); 
        byte []buf = (""+c).getBytes(); 
        buffer[j++] = (char)buf[0]; 
        buffer[j++] = (char)buf[1]; 
      } 
      else { 
        buffer[j++] = s.charAt(i); 
      } 
     }  
     return new String(buffer, 0, j); 

    除使用以上两个方法之外,有些JDBC driver如果对jdbc driver Manager设置了正确 的字符集属性,以上2个方法就不需要了.
      

  5.   

    你可以设置web服务器
    jboss中设置server.xml即可:
    <Connector port="8080" address="${jboss.bind.address}"
             maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
             emptySessionPath="true"
             enableLookups="false" redirectPort="8443" acceptCount="100"
             connectionTimeout="20000" disableUploadTimeout="true"         
             URIEncoding="GBK"/>
          <Connector port="8009" address="${jboss.bind.address}"
             emptySessionPath="true" enableLookups="false" redirectPort="8443" 
             protocol="AJP/1.3"
             URIEncoding="GBK"/>有两个server文件中都配上URIEncoding="GBK"就行了