Home Navigation

Thursday 9 July 2020

Spring mvc life cycle summary



  • First request lands to the different sort of filters and it applies to all request. eg, application provided filters, authentication filters etc
  • The DispatcherServlet consults with the HandlerMapping 
  • Handler Mapping resolves controller to invoke. Usually org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping is used. This class reads @RequestMapping annotation from the Controller and uses the method of Controller that matches with URL as Handler class.
  • Handler Adapter calls the appropriate controller. org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter is used. RequestMappingHandlerAdapter class calls the method of handler class (Controller) selected by HandlerMapping.
  • HandlerInterceptor to perform actions before handling, after handling or after completion (when the view is rendered) of a request.
  • Controller executes the business logic
  • Controller resolves the model and view to send to the user
  • The DispatcherServlet sends the view name to a ViewResolver to find the actual View to invoke. ViewResolvers resolves the view according to the implementation and configuration of the view, normally JSP org.springframework.web.servlet.view.InternalResourceViewResolver is used, Some other view resolvers are FreeMarkerViewResolver, TilesViewResolver, ThymeleafViewResolver, BeanNameViewResolver etc
  • Now the DispatcherServlet will pass the model object to the View to render the result.


No comments:

Post a Comment