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
- The input request from the browser is served by the Dispatcher Servlet.
- The Dispatcher Servlet gets the appropriate Controller from the Handler Mapping.By default, it uses BeanNameUrlHandlerMapping and DefaultAnnotationHandlerMapping, which is driven by @RequestMapping annotation.
- 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.
- 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.
- The View page is rendered as response by the Dispatcher Servlet to the Browser.