<%@ 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>
结果还是显示乱码,不知道错在哪里?
------解决方案--------------------
- Java code
<% request.setCharacrerEncoding("GBK"); // 增加这一句看看String str=request.getParameter("count");
------解决方案--------------------
你可以做一个过滤器.
或者在页面使用
request.setCharacterEncoding("GB2312");
response.setCharacterEncoding("GB2312");
或者使用
String str=new String(str.getBytes("ISO-8859-1"),"GB2312");
------解决方案--------------------
楼上正解
------解决方案--------------------
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>");