'Spring MVC request and response flow explanation

I can't find correct client request flow in below syntax.Could someone please clarify what is happening here?

Client(1) --> Dispatcher Servlet(2) --> Handler Mapping(3) --> Controller(4) -->
ModelAndView(5) --> viewResolver(6) --> View(7) --> Client(1) 

If possible please specify what are the corresponding spring classes/interfaces used in spring MVC process.



Solution 1:[1]

  1. Request will be received by DispatcherServlet.
  2. DispatcherServlet will take the help of HandlerMapping and get to know the @Controller class name associated with the given request.
  3. So request transfer to the @Controller, and then @Controller will process the request by executing appropriate methods and returns ModelAndView object (contains Model data and View name) back to the DispatcherServlet
  4. Now DispatcherServlet send the model object to the ViewResolver to get the actual view page.
  5. Finally, DispatcherServlet will pass the Model object to the View page to display the result.

Solution 2:[2]

Spring Flow First Request from JSP/HTML will hit the dispacher servlet, Based on the xml file it will go to particular controller, After going to controller it search for request mapping , based on request mapping it will go to the particular method and follows instructions and takes the model and view and give it to view resolver via dispacher servlet and view resolver will display the view.

Solution 3:[3]

I supplement the above explanations. request flow is like below.

Client --> WAS(go through filters) --> DispatcherServlet.doService, doDispatch --> Dispatcher Servlet.handlerMapping,hanlderAdapter --> Controller return ModelAndView --> DispatcherServlet.processDispatchResult, render, resolveViewName --> View --> Client.

I think debugging DispatcherServlet's methods with break points is a good way to understand request flow.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Singupurapu prudhvi raj
Solution 3