<%@ page contentType="text/html;charset=GBK" %>
在 JSP页面加上这个试试,
可能数据库的字体类型与显示的类型不一样,你需要做相应的转换。

解决方案 »

  1.   

    加上request.setCharacterEncoding("GB2312");
    试试
      

  2.   

    确保每个步骤里的字符集你都知道,在关键步骤做好转换
    或者都为UTF-8好处理
      

  3.   

    miaoliujun(傲龙) ( )  :怎么做啊具体,我看到表里也都是中文啊,可显示出来就??了,
    而且我也加了上面的那些
      

  4.   

    我的代码如下:
    <%@ page language="java" contentType="text/html;charset=GB2312"%>
    <%!
       public String getStr(String str) {
            try {
                 String tempstring=str;
                 byte[] tempstr=tempstring.getBytes("ISO8859-1");
                 String temp=new String(tempstr);
                 return temp;
            }
            catch(Exception e) {
            }
            return "null";
       }
    %>
    <%
      //request.setCharacterEncoding("GB2312");
      String uname=getStr("blue蜜蜂");
      String upassword=getStr("blue蜜蜂");  out.println("uname=" + uname + "<BR>");
      out.println("upassword=" + upassword + "<BR>");
    %>
    结果显示乱码哦,麻烦各位看看.
      

  5.   

    str=String(要转换的字符串.getBytes("ISO8859_1"), "GB2312")
    然后 select * from 表 where 字段=str  
    应该就可以了 如果还不行 再把结果集的字段.getBytes("GB2312I"), "SO8859_1")
      

  6.   

    楼主还不行吗? 你只用这一句试一试  
    str=new String(要转换的字符串.getBytes("ISO8859_1"), "GB2312");
    str是用来显示 数据库操作是不用来转换的 
      

  7.   

    晕,那楼主试试这个
    http://community.csdn.net/Expert/topic/3582/3582938.xml?temp=.8806421
      

  8.   

    jdbc:mysql://localhost:3306;useUnicode=true&characterEncoding=gb2312
      

  9.   

    用下面这句话,
    <%@ page language="java" contentType="text/html;charset=GB2312"%>
    ,同时还要对每个输出的地方加上转换函数,上面就有人说了实在不行可以尝试以下
    <%@ page language="java" contentType="text/html;charset=ISO8859_1"%>
    将内码转成iso8859_1的形式,这样做不要任何的字符转换,不过每次打开编辑文件时该CHARSET都会自动变成GB2312,可能是操作系统的问题
      

  10.   

    jdbc:mysql://localhost:3306/数据库名?useUnicode=true&characterEncoding=GB2312&autoReconnect=true
      

  11.   

    楼主这是mysql里字符集设置的问题
    show variables like "%char%";
    show variables like "%colle%";你就能看到你msyql字符集设置了,如果不是gbk,可以改过来
    相关信息去csdn的mysql栏找
      

  12.   


    '=====================================================
    http://community.csdn.net/Expert/topic/3660/3660057.xml?temp=.4793817
      

  13.   

    加上<%@ page contentType="text/html;charset=GBK" %>
    存入数据库的时候,仿照s=new String(s.getBytes("GBK"),"ISO-8859-1")转化为8859-1,取出来的时候,相反方向转化一下
      

  14.   

    加上
    <% request.setCharacterEncoding("gb2312");%>
    肯定行
      

  15.   

    写一个函数
    public string getStr(String str)
    {
    try{
       String temp_p=str;
       byte[] temp_t=temp_p.getBytes("GBK");
       String temp=new String(temp_t,"ISO8859_1");
       return temp;
       }catch(Exception e)
       {e.printStackTrace();}
      return "null";
    }
    然后再读出数据时调用getStr()函数,比如getStr(rs.getString("m"));
      

  16.   

    我遇到的问题和你的差不多,
    1.在页面中上<% request.setCharacterEncoding("gb2312");%>2.在连库的BEAN上这样写
             conn=java.sql.DriverManager.getConnection("jdbc:mysql://"+DBServer+":3306/"+DBName+"?useUnicode=true&characterEncoding=gb2312", DBUser,DBPassword);                                         
      

  17.   

    建议重装系统,重装MYSQL,重装一切一切
      

  18.   

    String dburl = "jdbc:mysql://" + DBHOST + ":3306/" + DBSID+"?user="+DBUSER+"&password="+DBPASS+"&useUnicode=true&characterEncoding=gb2312";
    //jdbc:mysql://localhost:3306/EJBDB在数据库连接这块,把+"&useUnicode=true&characterEncoding=gb2312加到后面,就可以
      

  19.   

    <%@ page contentType="text/html;charset=MS932" %>
      

  20.   

    用Filter过虑器,我也遇到这样的问题的
    你若有《jsp应用编程》第二版 里面有完整代码
      

  21.   

    用上面讲的转码的方式应该可以解决,我昨天也遇到了这个问题,得注意的是:如果你的有关转码的代码是写在javabean里面,得把新的class文件重新加载进去,而且必须重启tomcat!试试啊,也许行哦!
      

  22.   

    to: loverisyour(我是民工又咋的,不能搞开发啊!) 民工和搞开发的最大区别就是,民工到年底,可以去上告,要工资,而我们不行