<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"
</head>

解决方案 »

  1.   

    谢谢,这样是可以的。但是我想将charset指定为gb2312而能正确显示的啊。因为页面中还包含其他gb2312中文。
    我在jsp里面这样转换编码:
    str = new String(str.getBytes("utf-8"),"gb2312");
    但还是乱码,不知道为什么,谢谢。
      

  2.   

    编码格式就是utf-8啊,而且不会乱码。因为用鼠标指定“utf-8”编码方式可以正常显示的。但是指定“gb2312”就乱码。现在问题是怎么将utf-8转换成gb2312,使指定“gb2312”时不会出现乱码
      

  3.   

    <%@ page language="java"import="java.sql.*"contentType="text/html;charset=gb2312"%>
      

  4.   

    <%@ page language="java"import="java.sql.*"contentType="text/html;charset=gb2312"%>
      

  5.   

    试啦,不行,这样指定没用啊。有办法将utf-8的中文转换成gb2312的吗?
      

  6.   


      private static final String  inCode = "ISO-8859-1";
      private static final String  outCode  = "gb2312";  //到数据库时用readString(String inputString)
      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;
        }
      }  //显示的时候用writeString(String inputString)
      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;
        }
      }
      

  7.   

    str = new String(str.getBytes("ISO8859_1"),"gb2312");
    试试看