日期:2014-05-20  浏览次数:20766 次

jakarta-tomcat-5.0.28 中文乱码
在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" />
---------------------------------




------解决方案--------------------
把get改成post
------解决方案--------------------
加个<%
request.setCharacterEncoding();
%>
------解决方案--------------------
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
再加个
<%
request.setCharacterEncoding();
%>
------解决方案--------------------
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
再加个
<%
request.setCharacterEncoding();
%>
------解决方案--------------------
试下4楼的办法,另外再检查下server.xml

------解决方案--------------------

<%@ page language="java" import="java.util.*"pageEncoding="GBK"%>
------解决方案--------------------
在<head></head>之间加以下代码
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
------解决方案--------------------
http://blog.csdn.net/yehell/archive/2008/01/08/2030165.aspx,
http://blog.csdn.net/yztommyhc/archive/2009/01/13/3765193.aspx,
这2篇文章你看看,或许有你需要的东西。
看看你的网页源文件是否是乱码。
------解决方案--------------------