在每个jsp页面中都添加下面如下代码:
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%
  request.serCharacterEncoding("GBK");
%>

解决方案 »

  1.   

    如果你在servlet中获取页面中的传过来的值时,你可以进行编码转换,确保不出现乱码!
    首先在servlet的相应的方法中添加request.setCharacterEncoding("GBK");
    然后取传过来的值:
    String name = client.getName();
    String clientname = new String(name.getBytes("ISO8859_1"), "gb2312");这样以后,你用out.print()输出的结果应该不会有乱码了。
      

  2.   

    是这样的
    你说的方法我都用过
    我在eclipse里面装个tomcat插件运行的话中文都可以被显示出来
    但是直接用tomcat运行的话就会出现我上面说的情况
      

  3.   

    中文问题真烦.上次我做了一个网页,在本地局域网内调试的好一切正常,一丢到INTERNET上的服务器就糟了,不知道问题出现在哪里..我申请的是免费JSP空间.有谁遇到过这问题的,请告知,[email protected].谢谢
      

  4.   

    我也遇到这个问题,tomcat4下是没有的,解决办法:(看全了!!!)
    在server.xml中加入了:
        <Connector 
    port="80"               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   debug="0" connectionTimeout="20000" 
    disableUploadTimeout="true" URIEncoding="UTF-8" />
    才把问题解决了,我的应用用的utf-8的编码,如果我要用GBK,是不是这个配置还要改,真是他妈恶心。
    后来又看到更好的一个解决办法,也就是不用这个参数,而是用
    useBodyEncodingForURI="true",这样一来,应用无论用什么编码方式,都不需要该tomcat的任何配置了。
    下面是这两个参数的说明:
    URIEncoding 
    This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, ISO-8859-1 will be used. 
    useBodyEncodingForURI 
    This specifies if the encoding specified in contentType should be used for URI query parameters, instead of using the URIEncoding. This setting is present for compatibility with Tomcat 4.1.x, where the encoding specified in the contentType, or explicitely set using Request.setCharacterEncoding method was also used for the parameters from the URL. The default value is false.