<%@ 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>
结果还是显示乱码,不知道错在哪里?
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>
结果还是显示乱码,不知道错在哪里?
解决方案 »
- httpclient连续访问网页获取数据,是否会遇到缓存
- 面试题JDK与JRE的区别?你知道多少?
- eclipse无法识别myeclipse创建的项目,各位大侠帮忙解决!
- jsp中数据库是mysql的请教如何进行 日期大小的比较?
- 问一个JSP与sqlserver连接的问题,JavaBean.
- tomcat问题-JSP站点(生管系统)可以运行,自己写的JSP不能运行
- JavaScript怎么把返回的json数据传递给flex组件
- 这个哪里出错了?
- tomcat里的虚拟目录之间能否共享Session ?
- js将一个图片移动到一个标签内
- jsp画面中,嵌入Applet后把弹出的div给覆盖了, 怎么让Applet显示在底层?
- com.microsoft.sqlserver.jdbc.SQLServerException: 将截断字符串或二进制数据。
request.setCharacrerEncoding("GBK"); // 增加这一句看看
String str=request.getParameter("count");
或者在页面使用
request.setCharacterEncoding("GB2312");
response.setCharacterEncoding("GB2312");
或者使用 String str=new String(str.getBytes("ISO-8859-1"),"GB2312");
response.setCharacterEncoding("GB2312");
或者使用 String str=new String(str.getBytes("ISO-8859-1"),"GB2312");
我的程序中就是用的这个方法。
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>");
如果使用表单的post方法则使用<%request.setCharacterEncoding("GB2312");%>
若使用表单的get方法或是直接在地址后面加上的参数则使用
String str=request.getParameter("count");
byte[] a=str.getBytes("ISO-8859-1");
str=new String(a,"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>还真不懂啊,我刚学