Spring Tutorial: Spring MVC (Model-View-Controller)

Spring MVC helps in building flexible and loosely coupled web applications. The Model-View-Controllerdesign pattern helps in separating the business logic, presentation logic and navigation logic. It provides an elegant solution to use MVC in Spring Framework with the help of DispatcherServlet.

When a request is sent to the Spring MVC Framework, the following takes place.

  • A request is received by DispatcherServlet.
  • The DispatcherServlet communicates with HandlerMapping and calls the Controller associated with the request.
  • The request is processed by the Controller by calling the appropriate service methods and a ModelAndView object to the DispatcherServlet is returned.
  • The view name is sent to a ViewResolver by the DispatcherServlet to find the actual View to invoke.
  • Now the model object DispatcherServlet is passed to View to render the result.
  • With the help of the model data, the View renders the result back to the user.