在a.jsp提交到b.jsp的时候用get方法,在b.jsp上可以正常显示,
但是,如果用post方法,在b.jsp上就会显示乱码。a.jsp如下:
<%@page contentType="text/html; charset=gbk" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<title>a.jsp</title>
</head>
<body>
这是a.jsp
<form name="form1" action="b.jsp" method="get">
<table>
<tr>
<td>user:<input type="text" name="user" value="中国"></td>
<td>pass:<input type="text" name="pass" value=""></td>
</tr>
<tr>
<td><input type="submit" name="login" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
-----------------------------------------------------------
b.jsp如下:
<%@page contentType="text/html; charset=gbk" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<title>b.jsp</title>
</head>
<body>
这是b.jsp</br>
user:<%= request.getParameter("user")%></br>
pass:<%= request.getParameter("pass")%>
</body>
</html>
--------------------------------------------------------------------
server.xml配置如下:
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" URIEncoding="gbk" />
---------------------------------------------------------------------
但是,如果用post方法,在b.jsp上就会显示乱码。a.jsp如下:
<%@page contentType="text/html; charset=gbk" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<title>a.jsp</title>
</head>
<body>
这是a.jsp
<form name="form1" action="b.jsp" method="get">
<table>
<tr>
<td>user:<input type="text" name="user" value="中国"></td>
<td>pass:<input type="text" name="pass" value=""></td>
</tr>
<tr>
<td><input type="submit" name="login" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
-----------------------------------------------------------
b.jsp如下:
<%@page contentType="text/html; charset=gbk" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<title>b.jsp</title>
</head>
<body>
这是b.jsp</br>
user:<%= request.getParameter("user")%></br>
pass:<%= request.getParameter("pass")%>
</body>
</html>
--------------------------------------------------------------------
server.xml配置如下:
<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" URIEncoding="gbk" />
---------------------------------------------------------------------
解决方案 »
- spring3中配置的事物无效
- Struts2默认拦截器问题..................................................................
- SSH extjs 数据传输的问题
- 关于JSP隐藏问题
- 关于在标签中调用spring的bean的问题
- jsp 如果何向bean 传参数并完成一个数据插入操作。
- 请问java怎样用URL构造一个File类?
- 请问,JAVA_HOME和J2EE_HOME这两个变量有什么作用?
- 真心问你们一个问题:学J2EE好找工作吗?有多少公司用J2EE开发系统?
- Java写的程序能在哪种PDA上运行?
- jk shared memory 是做什么用的?
- glassfish 连接总是报错
request.setCharacterEncoding();
%>
再加个
<%
request.setCharacterEncoding();
%>
再加个
<%
request.setCharacterEncoding();
%>
<%@ page language="java" import="java.util.*"pageEncoding="GBK"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
http://blog.csdn.net/yztommyhc/archive/2009/01/13/3765193.aspx,
这2篇文章你看看,或许有你需要的东西。
看看你的网页源文件是否是乱码。
http://topic.csdn.net/u/20080603/11/9584916d-310a-44f3-83eb-e2bb3e2a5b35.html
<% request.setCharacterEncoding();%> 还不行 就用
<%= new String(request.getParameter("user").getBytes("iso-8859-1"),"GBK") %>