我使用Tomcat7。我的项目结构是:
as1.jsp
as2.jsp
的内容web.xml
是:
<filter-mapping>
<filter-name>filter1</filter-name>
<url-pattern>/as1.jsp</url-pattern>
</filter-mapping>
filter1
在 HttpServletRequestWrapper 中使用:
...
RequestWrapper requestWrapper = new RequestWrapper(req);
requestWrapper.setParameter("params", new String[]{Item.getParams()});
chain.doFilter(requestWrapper, response);
......
的内容as1.jsp
是:
hi <br/>
<jsp:include page="as2.jsp">
<jsp:param name="test" value="true" />
</jsp:include>
的内容as2.jsp
是:
as2 runed
<br/>
test:<%= request.getParameter("test") %>
当我部署项目时,我得到了这个结果:
hi
as2 runed
test:null
当删除HttpServletRequestWrapper
时filter1
我得到正确的结果:
hi
as2 runed
test:true
请帮助我,如何request.getParameter("test")
进入?谢谢你。HttpServletRequestWrapper
filter1