You can also use SessionStatus.setComplete () as follows:
@RequestMapping(method = RequestMethod.GET, value="/clear") public ModelAndView clear(SessionStatus status, ModelMap model, HttpServletRequest request) { model.clear(); status.setComplete(); return new ModelAndView("somePage"); }
or 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"); }
I use it the way it is on one of my forms, which has a mulitple sessionAttributes, and I want to delete only one of them.
source share