请问一下当我用下面这条语句传递参数时:
<a href=response.jsp?txtContent=文字 >
respont.jsp? txtcontent=欢迎 大家好</a>
用request.getparameter("txtContent")接收时出现????的乱码,该如何解决啊?
传递页面encode.jsp如下:
<%@ page contentType="text/html; charset=GB2312" language="java" import="java.util.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>字符串编码</title>
</head>
<body>
<center>字符串编码</center>
<hr>
经过编码的字符串
<a href=response.jsp?txtContent=<%= java.net.URLEncoder.encode("欢迎 大家好")%> >
response.jsp? txtcontent=欢迎 大家好</a>
<hr>
未经过编码的字符串
<a href=response1.jsp?txtContent=文字 >
respont.jsp1? txtcontent="欢迎 大家好"</a>
</body>
</html>
接受页面response.jsp如下
<%@ page contentType="text/html; charset=gb2312"%>
<html>
<head>
<title>无标题文档</title>
</head>
<body>
<%request.setCharacterEncoding("gb2312");%>
得到的内容为:<%= request.getParameter("txtContent") %>
</body>
</html>