数据库中的内容是正确的(通过select语句查的),但是用JSP读取出来显示在页面中时,有的是正确的,而有的却是乱码?为什么??我在JSP中已经加入:
<%@ page contentType="text/html;charset=gb2312"%>
在显示时,也使用:
<td><div align="left"><span class="style10"><%=new String((rs.getString("name")).getBytes("gb2312"))%></span></div></td>但是都不行,怎么办????????我用的是:windows2000+jboss4.0.2+oracle9i+j2sdk1.4.2_09

解决方案 »

  1.   

    試試這個
    <%@ page language="java"  contentType="text/html;charset=gb2312"%>
      

  2.   

    我解决了!
    我在jsp中使用了下面的语句:
     stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); 
     rs=stmt.executeQuery(sql);把它改为:
      stmt=conn.createStatement(); 
     rs=stmt.executeQuery(sql);就正常了。
    谁知道是怎么回事?
      

  3.   

    返回时出现字符集错误码。
    jsp页面保存到数据库有乱码解决方法Jsp+tomcat+bean中文乱码问题解决方法javabean中参数有乱码
    1) 所有的jsp页面指定字符编码方式,如:Charest=gb2312,Charest=UTF-8等等
    2) 在应用服务器中的server.xml方件中找到设置服务器端口的行,一般是这样开头:”<Connector port="8080"”,
    3) 在找到的行"<Connector"开头的字符串后加上:URIEncoding="UTF-8" ,保存文件
    --------------------------------------------------------------------------
    jsp页面有乱码解决方法    所有的jsp页面指定字符编码方式,如:Charest=gb2312,Charest=UTF-8等等
        <%@ page contentType="text/html; charset=UTF-8">
    --------------------------------------------------------------------------
    jsp单个中文参数乱码解决方法    用这个转换一下: 
        <%!String trans(String chi)
           {
            string result =null;
            byte temp[];
            temp=chi.getBytes("iso=8859-1");
            result= new String(temp);
            }
        %>
    或者直接这样:
        <% 
          request.setCharacterEncoding("UTF-8");
          out.println(request.getParameter("参数ID")
        %>
    --------------------------------------------------------------------------
      

  4.   

    try
    {
    this.text1=new String(text1.getBytes("ISO-8859-1"),"GBK");
    }
    catch(Exception e1)
    {
    }