<%@page contentType="text/html"%>
<%@ page pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<jsp:useBean id="JDBCCONN" class="test.JDBCCONN"/>        <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>设备添加</title>
    </head>
    <body bgcolor="Silver">
        
    <%Connection con1=JDBCCONN.getConnection();    %>    
    <h1></h1>
    <table   cellpadding="3" cellspacing="1" align="center" width="800"   > 
        <tr align="center"  >
            <td width="25%"  bgcolor="#009933" >商品名</td>
            <td width="10%"  bgcolor="#009933" >所属系列</td>
            <td width="10%"  bgcolor="#009933" >所属工程系列</td>
            <td width="10%"  bgcolor="#009933" >公司名称</td>
            <td width="10%"  bgcolor="#009933" >参数</td>
            <td width="10%"  bgcolor="#009933" >图片</td>
            
        </tr>
        <%
        request.setCharacterEncoding("GBK");         Statement stmt2=con1.createStatement();
        String sql="";
        sql="select * from equi_view"; 
        ResultSet rs=stmt2.executeQuery(sql);
        i=(Page-1)*PageSize;
        for(j=0;j<i;j++)
        rs.next();
        i=0;
        
        while(i<PageSize && rs.next())
            {%>
                
            <tr align="center" >
                <td width="25%"  bgcolor="#efefef"  ><%=rs.getString("Name_S")%></td>
                <td width="10%"  bgcolor="#efefef"  ><%=rs.getString("Name_M")%></td>
                <td width="10%"  bgcolor="#efefef" ><%=rs.getString("Name_L")%></td>
                <td width="10%"  bgcolor="#efefef" ><%=rs.getString("Corp_N")%></td>
                <td width="10%"  bgcolor="#efefef" ><%=rs.getString("Para")%></td>
                <td width="10%"  bgcolor="#efefef" ><%=rs.getString("Photo")%></td>
            </tr>
        <% 
            i++;          
        }
        %>    </table>
            <%
        
       
        stmt2.close();
        con1.close();
        %>   
        </body>
</html>得出结果出现乱码,今天找了一天论坛,都不能解决,请大侠指点(使用sql 2000数据库)。web.xml为"UTF-8"标准        

解决方案 »

  1.   

      用这个编码试一下了.
    pageEncoding="GB2312"
      

  2.   

    你这个页面没必要写两个字符集为"UTF-8",而且,你若是在将数据保存到DB为乱码的话,就写个过滤器,若是返回的是乱码,就在servlet(或JSP) 中设定返回的字符集,只要字符集统一,就应该没问题了!
      

  3.   

    在head中加入 <%request.setCharacterEncoding("GBK");%>
    这句话看看好使不?
    呵呵
      

  4.   


    public class stringCode{
      public String codeToString(String str)
      {
        String s = str;
    try
    {
      byte tempB[] = s.getBytes("ISO-8859-1");
      s = new String(tempB);
      return s;
    }
    catch(Exception e)
    {
      return s;
    }
      }}
    stringCode cop = new stringCode();
    //如果传递过来的参数是中文的;
    String receive = cop.codeToString(参数);
      

  5.   

    前2行改成
    <%@page contentType="text/html;charset=GBK" pageEncoding="GBK"%> 
    <% request.setCharacterEncoding("GBK");   %>
      

  6.   

    ???ì  ????  ????  (使用java2000_net的方法,生成的结果)
     ºìÍâÉãÏñ»ú  ÉãÏñ»ú  ¹ãÖÝ  (使用UTF-8生成的结果)之前使用gb2312,数据库为access是没事的,改用sql 2000就不会了
      

  7.   

    采用过滤器吧,省得每个文件都设置
    在tomcat的webapps\servlets-examples\WEB-INF\classes\filters目录下有个SetCharacterEncodingFilter.Java,把这个复制出来
    在你项目的web.xml中加以下的代码:
    <filter>
    <filter-name>Set Character Encoding</filter-name>
    <filter-class>com.aa.filter.SetCharacterEncodingFilter</filter-class>(这里是SetCharacterEncodingFilter.Java的路径)
    <init-param>
    <param-name>encoding</param-name>
    <param-value>UTF-8</param-value>(这里要和jsp页面中的编码 统一)
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
      

  8.   

    JSP页面中也可以设置下
    <%@page contentType="text/html;charset=UTF-8"%> 
    <% request.setCharacterEncoding("UTF-8");   %>
      

  9.   

    用了,也不行package SetCharacterEncodingFilter.java;import java.io.IOException; import javax.servlet.Filter; 
    import javax.servlet.FilterChain; 
    import javax.servlet.FilterConfig; 
    import javax.servlet.ServletException; 
    import javax.servlet.ServletRequest; 
    import javax.servlet.ServletResponse; public class SetCharacterEncodingFilter implements Filter 

    protected String encoding = null; 
    protected FilterConfig filterConfig = null; 
    protected boolean ignore = true; public void destroy() 

    this.encoding = null; 
    this.filterConfig = null; 
    } public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) 
    throws IOException, ServletException 

    if (ignore || (request.getCharacterEncoding() == null)) 

    // System.out.println(request.getCharacterEncoding()); String encoding = selectEncoding(request); 
    if (encoding != null) 
    // System.out.println(encoding); 
    request.setCharacterEncoding(encoding); 

    chain.doFilter(request, response); 
    } public void init(FilterConfig filterConfig) throws ServletException 

    this.filterConfig = filterConfig; 
    this.encoding = filterConfig.getInitParameter("encoding"); 
    String value = filterConfig.getInitParameter("ignore"); 
    if (value == null) 
    this.ignore = true; 
    else if (value.equalsIgnoreCase("true")) 
    this.ignore = true; 
    else if (value.equalsIgnoreCase("yes")) 
    this.ignore = true; 
    else 
    this.ignore = false; 
    } protected String selectEncoding(ServletRequest request) 

    return (this.encoding); 


     <filter> 
    <filter-name>encoding</filter-name> 
    <filter-class> 
    SetCharacterEncodingFilter.java.SetCharacterEncodingFilter 
    </filter-class> 
    <init-param> 
    <param-name>encoding</param-name> 
    <param-value>utf-8</param-value> 
    </init-param> 
    </filter> 
    <filter-mapping> 
    <filter-name>encoding</filter-name> 
    <filter-name>encoding</filter-name> 
    <url-pattern>/*</url-pattern> 
    </filter-mapping>
      

  10.   

    怎么查sql 2000的字体的啊
      

  11.   

    <%@   page   pageEncoding="UTF-8"%> 
    编码要一致
      

  12.   

    <%@page contentType="text/html;charset=GBK" pageEncoding="GBK"%> 
    <% request.setCharacterEncoding("GBK");   %>  
    编码 一定要一致  !!!!   
    在不好 用就 去  jsp  里的java 代码 里面 改 !!!  
    例如 :  <%=new String(((String)request.getParameter("componentWindowSearchTip")).getBytes("ISO8859_1"),"GBK")%>  
    将 String 对象 用 字节流  进行 编码 转换  ,  如果在 不好用 你就把  ISO8859_1  改成 其他 编码 格式 
      

  13.   

    晕,数据库肯定不是GBK的吧,我现在也是这种问题啊,郁闷ing
      

  14.   

    你不是说数据库中没乱码么?一、过滤器一定要用。
    二、你仔细检查下你的代码,要全部的编码一致。建议你都用"UTF-8”页面中处理这几个方法
    <%page contentType="text/html; charset=UTF-8"%>
    request.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=UTF-8");还有一个就是Tomcat中的server.xml中的
    <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
        <Connector port="8080"
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   debug="0" connectionTimeout="20000" 
                   disableUploadTimeout="true" URIEncoding = "UTF-8" />
        <!-- Note : To disable connection timeouts, set connectionTimeout value
         to 0 -->
    也修改一下,添加了一个URIEncoding = "UTF-8" 
      

  15.   

    还不好使!那就这么玩 !!!   
    把 你上面的 java代码 扔到 java 类 里面去 ,别写在jsp 上 ,  那块的 html 标记 也可以 写在 java 类里 ,例如 StringBuffer buffer = new StringBuffer();buffer.append("<table width=\"200\">\n");  就可以了 ,在 java  那边看不出乱码在 弄回 jsp 上看, 使用 Servlet  + AJAX  实现 
      

  16.   

    它从数据库读出来与输入的中文比较可以比较出来的,但显示出来就是乱码,全部用UTF-8的,现在就差数据库不能确定是用那种
      

  17.   

    <html>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <head>
    这样试试``肯定会OK!
      

  18.   

    终于解决了,原来数据库用了非Unicode码,所以不行,修改为Unicode码后,就可以了,多谢以上帮忙的同志,衷心感谢,并祝君2008事业更上一层楼
      

  19.   

    scope="session"  证明能给你把它存在session里面了
    所以servlet只能通过session得到
      

  20.   

    无满意结贴,晕,这分都还给CSDN了
      

  21.   

    此兰州太不厚道了;楼上那些那么帮你;你还无满意?%E%d3%2432%dD2%e  此乱码是骂你的.