The main entry point for a web request in a Spring MVC application is via the Dispatcher servlet. The Dispatcher servlet acts as a front controller and dispatches the requests to the other controller. The front controller's main duty is to find the appropriate right controller to hand over the request for further processing. The following diagram shows an overview of the request flow in a Spring MVC application:
The Spring MVC request flow
Okay, let's review the Spring MVC request flow in short:
When we enter a URL in the browser, the request comes to the Dispatcher servlet. The Dispatcher servlet acts as a centralized entry point to the web application.
The Dispatcher servlet determines a suitable controller that is capable of handling the request and dispatching that request to the controller.
The controller method updates the objects in the model and returns the logical view name and updated model to the Dispatcher servlet.
The Dispatcher servlet consults with view resolver to determine which view to render and passes the model's data to that view.
View furnishes the dynamic values in the web page using the model's data and renders the final web page and returns that web page to the Dispatcher servlet.
At the end, the Dispatcher servlet returns the final rendered page as a response to the browser.