我是从一个JSP页面请求到另一个带有一些参数的JSP页面,代码是:
url="/hotModuel/baseinfo/siteinfo/commonPlaceAndUnit/commonPlaceAndUnitStatistics.jsp?keyType=SecurityKeyOther&sid=e13048f7-d253-4d50-acec-2981a5536d48";
$.ajax({
url : url,
cache: false,
success : function(result) {
proccessLoginResult(result,function(){
$("#loading").hide();
$("#contentDiv").html(result);
setOrgSelect();
setCrumbs(srcObj);
});
}
});
在commonPlaceAndUnitStatistics.jsp文件中,我使用请求获取参数,代码为:
<%
String keyType = request.getParameter("keyType");
String sid= request.getParameter("sid");
%>
得到keyType的值为
SecurityKeyOthersid = e13048f7-d253-4d50-ACEC-2981a5536d48
sid的值是
e13048f7-d253-4d50-ACEC-2981a5536d48
但在过滤器中获取参数:
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse, FilterChain chain)
throws IOException, ServletException {
String keyType= request.getParameter("keyType");
String sid= request.getParameter("sid");
}
两个参数的值是对的,为什么会这样?
答案 0 :(得分:1)
按照预期打印,当我发送网址时,
<a href="two.jsp?keytype=something&sid=1234567&key2=value2">Click me!</a>
打印时,
<%= request.getParameter("keytype") %><br/>
<%= request.getParameter("sid") %> <br />
<%= request.getParameter("key2") %> <br/>
将输出,
东西
1234567
值2
答案 1 :(得分:0)
您可以在Ajax请求上尝试此操作吗?
将网址更改为:url="/hotModuel/baseinfo/siteinfo/commonPlaceAndUnit/commonPlaceAndUnitStatistics.jsp.
并将参数放入ajax请求的主体中:
$.ajax({
url : url,
data : { keyType: SecurityKeyOther, sid: e13048f7-d253-4d50-acec-2981a5536d48},
cache: false,
success : function(result) {
proccessLoginResult(result,function(){
$("#loading").hide();
$("#contentDiv").html(result);
setOrgSelect();
setCrumbs(srcObj);
});
}
});