9

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.

Harshal Patil
  • 6,659
  • 8
  • 41
  • 57
Balasubramani
  • 645
  • 3
  • 9
  • 16
  • read section 7.1 [here](http://www.manning.com/walls4/Sample-Ch07.pdf) for basics and complete chapter 7 for end to end understanding. – Bond - Java Bond Jan 13 '15 at 10:37
  • http://javadecodedquestions.blogspot.in/2013/03/understanding-spring-mvc.html – RBP Jan 13 '15 at 11:28
  • You can find good explanation here [https://stackoverflow.com/a/14015907/3425489](https://stackoverflow.com/a/14015907/3425489) – Shantaram Tupe Mar 15 '18 at 07:12
  • [How Spring MVC Framework works? How HTTP Request is processed?](https://javarevisited.blogspot.com/2017/06/how-spring-mvc-framework-works-web-flow.html) – Jason Law Mar 22 '20 at 01:20

3 Answers3

17
  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.
Harshal Patil
  • 6,659
  • 8
  • 41
  • 57
1

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.

0

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.

Roon
  • 81
  • 1
  • 3