Spring MVC Execution Flow

Spring MVC Execution Flow
Spring MVC Execution Flow Diagram

The above diagram depicts the Spring MVC Execution Flow.

The DispatcherServlet is a front controller like it provides a single entry point for a client request to Spring MVC web application and forwards request to Spring MVC controllers for processing.

Steps in the Spring
  1. The input request from the browser is served by the Dispatcher Servlet.
  2. The Dispatcher Servlet gets the appropriate Controller from the Handler Mapping.By default, it uses BeanNameUrlHandlerMapping and DefaultAnnotationHandlerMapping, which is driven by @RequestMapping annotation.
  3. The apt Controller is invoked. The identified Controller interacts with View and Model to generate the ModelAndView Object(it contains logical view name and model) and passes it back to the Dispatcher Servlet.
  4. The Dispatcher Servlet passes the ModelAndView to the View Resolver which creates the actual View object and gives it back to the Dispatcher Servlet.By default, DispatcherServlet uses InternalResourceViewResolver(ViewResolver implementation) to convert logical view name to actual View object.
  5. The View page is rendered as response by the Dispatcher Servlet to the Browser.

Leave a Reply

Your email address will not be published. Required fields are marked *