Spring Book – Chapter 14 – Spring MVC and Spring Web Flow

Having understood the overall architecture of Spring MVC, Figure 14-4 below pictorially represents the flow of request through various objects in Spring MVC ecosystem.

Request flow in a typical Spring MVC web application

Figure 14-4. Request flow in a typical Spring MVC web application

The flow of request through various Spring MVC objects can be summarized in order as shown below:

  1. The client requests for a resource from the server and the request is intercepted by the DispatcherServlet.
  2. The DispatcherServlet finds the appropriate HandlerMapping.
  3. The HandlerMapping is responsible for mapping the client request and the appropriate Controller with the help from either Spring configuration file or annotations declared in the classes. Once it determines appropriate Controller, it dispatches the request to the Controller.
  4. The Controller executes the necessary business logic as necessary and then returns ModelAndView object back to the DispatcherServlet.
  5. Looking at the values in the ModelAndView object and with the help from ViewResolver object, Spring MVC derives the actual View to be rendered.
  6. The View object is generated and then sent to the DispactherServlet, which will send it to the Servlet Container to generate the final out which will be sent back to the client.

Figure 14-5 shown below when closely looked, reveals more Spring MVC based objects in the overall request lifecycle in Spring MVC ecosystem. The figure is self-explanatory, and as a single figure can speak louder than a paragraph of words, I felt putting this figure as part of this section explaining Spring MVC’s architecture.

Spring MVC Request Lifecycle

Figure 14-5. Spring MVC Request Lifecycle

On the same lines, Figure 14-6 below shows a simplified version of Spring MVC’s sequence diagram.

Simplified sequence diagram of Spring MVC

Figure 14-6. Simplified sequence diagram of Spring MVC

Page Visitors: 8091

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

Leave a Reply

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