a.jsp?username=姓名inga.jsp代码如下:
<%
response.setContentType("text/html;charset=gb2312");
request.setCharacterEncoding("gb2312");
String accounts = new String(request.getParameter("Username").getBytes("iso-8859-1"), "gb2312"); 
out.print(accounts);
%>
出乱码了!上面的方法不灵了!

解决方案 »

  1.   

    你获得姓名的就出现乱码了。
    在tomcat中修改一下service.xml就可以了。
    修改tomcat的server.xml文件中URIEncoding。
    <Connector
    debug="0"
    acceptCount="100"
    connectionTimeout="20000"
    disableUploadTimeout="true"
    port="80"
    redirectPort="8443"
    enableLookups="false"
    minSpareThreads="25"
    maxSpareThreads="75"
    maxThreads="150"
    maxPostSize="0"
    URIEncoding="GBK"
    >
    </Connector>
    这个方法主要针对从url中获取字符串的问题。
    在tomcat5.0及以上版本,post和get方法在处理编码时有所不同。如果你在url中获取中文就会出现?号。但在tomcat4.1版本没有问题,因为tomcat4.1的post和get方法在处理编码时是一样的。
      

  2.   

    试过了,还是不行啊!急ing!!!!!!!!
      

  3.   

    地址栏里显示:http://localhost:8080/web/investigate/okaccounts.jsp?Username=?衃
    页面显示:??[ 
    乱码显示的还不一样呢!郁闷死了
      

  4.   

    用下面这段代码试一下:
    String accounts=request.getParameter("Username").toString();
    byte temp[] =N_Body.getBytes("ISO-8859-1");
    accounts=new String(temp);
    out.print(accounts);
      

  5.   

    不好意思,上面写错了一点,把第二行的N_Body改成accounts就可以了:
    String accounts=request.getParameter("Username").toString();
    byte temp[] =str1.getBytes("ISO-8859-1");
    accounts=new String(temp);
    out.print(accounts);