Nic*_*las 4 java model-view-controller session spring http
这个问题听起来很奇怪,我正在玩Spring MVC并试图在两个页面之间移动,基本上我是使用Spring Form JSTL创建一个JSP页面,所以它只使用一个POST,我使用一个控制器来移动一个页面到下一个.但模型在页面之间丢失,我想隐藏实际变量,因此QueryStrings是不可能的(据我所知).我知道我可以使用InternalResourceView,但只允许我使用模型.
我想传输一个对该页面是独占的变量,没有模型或使用QueryStrings的最佳方法是什么?
我打算使用SessionAttribute来轻松定义它们,但是想知道,如何删除SessionAttribute创建的变量?我尝试了HttpSession.removeAttribute,它似乎没有用.
您也可以像这样使用SessionStatus.setComplete():
@RequestMapping(method = RequestMethod.GET, value="/clear")
public ModelAndView clear(SessionStatus status, ModelMap model, HttpServletRequest request) {
model.clear();
status.setComplete();
return new ModelAndView("somePage");
}
Run Code Online (Sandbox Code Playgroud)
或DefaultSessionAttributeStore.cleanUpAttribute像这样:
@RequestMapping(method = RequestMethod.GET, value="/clear")
public ModelAndView clear(DefaultSessionAttributeStore status, WebRequest request, ModelMap model) {
model.remove("mySessionVar");
status.cleanupAttribute(request, "mySessionVar");
return new ModelAndView("somePage");
}
Run Code Online (Sandbox Code Playgroud)
我在我的一个有多个sessionAttributes的表单上使用它,我想只删除其中一个.
归档时间: |
|
查看次数: |
6968 次 |
最近记录: |