<%@ page contentType="text/html; charset=GBK" %>
<%
request.setCharacterEncoding("GB2312");//设置编码
%>

解决方案 »

  1.   

    加上这句:<meta content="text/html;charset=gb2312" http-equiv="Content-Type">
      

  2.   

    <%
    request.setCharacterEncoding("GB2312");//设置编码
    %>报出错
    加上
    <meta content="text/html;charset=gb2312" http-equiv="Content-Type">
    还是乱码
      

  3.   

    我用的JDK + Tomcat4,以下两种方法都没有问题:
    1、
    <%@page contentType="text/html;charset=gb2312"%>2、
    <%@ page contentType="text/html; charset=GBK" %>
    <% request.setCharacterEncoding("GB2312");//设置编码 %>
      

  4.   

    有<%@page contentType="text/html;charset=gb2312"%>应该就可以了!!
      

  5.   

    String str="你好";
    new String(str.getBytes("ISO8859_1"),"GBK");
    多换几种编码试试吧!与系统有关!
      

  6.   

    我的<%@page contentType="text/html;charset=gb2312"%>也没问题啊
      

  7.   

    jdk1.4.1 我也
    试了,好象还是不行啊
      

  8.   

    解决办法:  
    第一:  
     1:在jsp页面加入:  
    <%@  page  contentType="text/html;  charset=gb2312"  %>  
     2:在servlet里面:  
       public  void  doGet(HttpServletRequest  request,  HttpServletResponse  response)  throws  ServletException,  IOException  {  
           response.setContentType("text/html;  charset=gb2312");//这是重要的  
     
    3:上面的如果在不行就用如下的方法在数据入库前进行调用:  
    public  static  String  UnicodeToChinese(String  s){  
       try{  
             if(s==null  &brvbar;  &brvbar;s.equals(""))  return  "";  
             String  newstring=null;  
             newstring=new  String(s.getBytes("ISO8859-1"),"gb2312");  
             return  newstring;  
           }  
       catch(UnsupportedEncodingException  e)  
       {  
       return  s;  
       }  
       }  
     
    public  static  String  ChineseToUnicode(String  s){  
       try{  
       if(s==null  &brvbar;  &brvbar;s.equals(""))  return  "";  
       String  newstring=null;  
       newstring=new  String(s.getBytes("gb2312"),"ISO8859-1");  
         return  newstring;  
       }  
       catch(UnsupportedEncodingException  e)  
       {  
       return  s;  
     }  
       }