How to do it...

To implement page redirection with Flash-scoped objects, apply these steps:

  1. To start our experiment on implementing page redirection, let us create a controller that loads a login form, processes the username and password, and then redirects to another form controller through Spring's old way of page navigation, that is, through RedirectView:
@Controller public class RedirectPageController { @RequestMapping(value="/login.html", method=RequestMethod.GET) public String login(){ return "login"; } @RequestMapping(value="/jump_page.html", method=RequestMethod.POST) public RedirectView sendRedirection(RedirectAttributes atts, @RequestParam("username") String username, @RequestParam("password") String password){ atts.addFlashAttribute("username", ...

Get Spring 5.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.