Spring MVC Architecture

Learn about the Spring MVC architecture and how it differs from the Servlets and JSP model.

Spring MVC is a framework for building web applications in Java which is based on the MVC design pattern. It uses the features of the core spring framework like Inversion of Control (IoC) and dependency injection.

Spring MVC request flow

In a nutshell, a request coming from the client is handled by the Spring MVC front controller which delegates the request to another controller. The controller creates a model and based on the user request, populates the model. Then it returns the model to the front controller. Now, the front controller passes this model to the view template which takes the data and renders the response to the client.

MVC architecture has a front controller that manages all the other controllers. The developer creates the controllers for the application and Spring MVC provides the front controller. The job of the front controller is to handle all requests coming from the client. The web.xml file, which is the entry point of a web application, contains the servlet mapping of the front controller such that all requests are forwarded to it. It is the job of the front controller to call another controller based on the request that it receives.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.