在请求中保留url参数

时间:2012-04-21 08:10:26

标签: spring spring-mvc url-parameters

我正在使用Spring MVC。需要一些用户选择全局保留并始终保留在url参数中。我也许可以随意删除它。

对于Spring MVC,是否存在类似Persistent Page Data(如Tapestry http://tapestry.apache.org/persistent-page-data.html)的内容。

指向无法回答的类似问题的链接:http://osdir.com/ml/java.appfuse.user/2005-08/msg00507.html 感谢

更新

最终我使用了一种简单的技术,其中: 1.我会使用查询参数捕获当前页面网址。 2.在此网址中添加或替换新参数。

<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="servletPath" value="${requestScope['javax.servlet.forward.servlet_path']}"></c:set>
<c:set var="currentPath" value="${contextPath}${servletPath}"></c:set>

<a href="${fn:replaceUrlParameter(currentPath,'age','1') }">ageone</a>

其中replaceUrlParameter()使用正则表达式替换或添加查询参数。

1 个答案:

答案 0 :(得分:2)

将此参数保留在会话中并编写将其添加到任何请求的Servlet过滤器,或者修改请求URL以使其在URL中可见。