<%@ page language="java" contentType="text/html; charset=GB2312"
    pageEncoding="GB2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>request</title>
</head>
<body>
<font size=3 color=#ee0000>
欢迎来到核算中心
</font>
<hr>
<%
String str=request.getParameter("count");
byte[] a=str.getBytes("ISO-8859-1");
str=new String(a);
out.println("您的帐号是:"+str);
out.println("<br>");
 
String str2=request.getParameter("pwd");
byte[] b=str2.getBytes("ISO-8859-1");
String strb=new String(b);
out.println("您的密码是:"+strb);
out.println("<br>");

%></body>
</html>
结果还是显示乱码,不知道错在哪里?

解决方案 »

  1.   

    <% 
    request.setCharacrerEncoding("GBK"); // 增加这一句看看
    String str=request.getParameter("count"); 
      

  2.   

    你可以做一个过滤器.
    或者在页面使用 
    request.setCharacterEncoding("GB2312");
    response.setCharacterEncoding("GB2312");
    或者使用  String str=new String(str.getBytes("ISO-8859-1"),"GB2312");  
      

  3.   

    呵呵,request.setCharacterEncoding("GB2312"); 
    response.setCharacterEncoding("GB2312"); 
    或者使用   String str=new String(str.getBytes("ISO-8859-1"),"GB2312"); 
    我的程序中就是用的这个方法。
      

  4.   

    String str=request.getParameter("count");
    byte[] a=str.getBytes("ISO-8859-1");
    str=new String(a,,"gb2312");
    out.println("您的帐号是:"+str);
    out.println(" <br>");String str2=request.getParameter("pwd");
    byte[] b=str2.getBytes("ISO-8859-1");
    String strb=new String(b,"gb2312");
    out.println("您的密码是:"+strb);
    out.println(" <br>");
      

  5.   

    你是用什么方法传参的啊?
    如果使用表单的post方法则使用<%request.setCharacterEncoding("GB2312");%>
    若使用表单的get方法或是直接在地址后面加上的参数则使用
    String str=request.getParameter("count");
    byte[] a=str.getBytes("ISO-8859-1");
    str=new String(a,"GB2312");
      

  6.   

    <%@ page language="java" contentType="text/html; charset=GB2312"
      pageEncoding="GB2312"%>
    <!DOCTYPE HTML PUBLIC "-//W3Cwww.cctv40.com//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GB2312">
    <title>request</title>
    </head>
    <body>
    <font size=3 color=#ee0000>
    欢迎来到核算中心
    </font>
    <hr>
    <%
    String str=request.getParameter("count");
    byte[] a=str.getBytes("ISO-8859-1");
    str=new String(a);
    out.println("您的帐号是:"+str);
    out.println("<br>");
      
    String str2=request.getParameter("pwd");
    byte[] b=str2.getBytes("ISO-8859-1");
    String strb=new String(b);
    out.println("您的密码是:"+strb);
    out.println("<br>");%></body>
    </html>还真不懂啊,我刚学