Sometimes it is necessary to display status information (a confirmation message, for instance) as result of a POST handler. Spring MVC provides the concept of "Flash Attributes": Attributes that can be passed to the handler receiving a redirected request, for example:
public ModelAndView handleRequest(..., RedirectAttributes redirectAttributes) { // handle request redirectAttributes.addFlashAttribute( "status", "Everything is fine."); // send redirect using // HandlerHelper#redirectTo() or // a org.springframework.web.servlet.view.RedirectView }
Also, see this post on Tikal.com.
Note | |
---|---|
Because of SPR-10516 any beans
added as objects to ModelAndView are converted to Strings (and might require to add a converter
to |