Flow 4 - Controller redirecting to a View with ModelAndView

In the previous flow, we returned a view name and populated the model with attributes to be used in the view. Spring MVC provides an alternate approach using ModelAndView. The controller method can return a ModelAndView object with the view name and appropriate attributes in the Model. In this flow, we will explore this alternate approach.

Get Mastering Spring 5.0 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.