Spring MVC Framework

Ritik Goel
2 min readMar 21, 2021

What is Spring MVC?

It is a Java framework that is used to build web applications. It follows the Model-View-Controller design pattern. Not just that, it also implements all the basic features of a core Spring Framework like Inversion of Control, Dependency Injection. Spring MVC provides a dignified solution to use MVC in Spring Framework with the help of DispatcherServlet. In this case, DispatcherServlet is a class that receives the incoming request and maps it to the right resource such as Controllers, Models, and Views.

Spring Web Model View Controller

It comprises four main components:

  • Model — Model contains the core data of the application. Data can either be a single object or a group of objects.
  • Controller — It contains the business logic of an application. You can use @Controller annotation to mark the class as Controller.
  • View — Basically, the View is used to represent the information in a particular format. Here, you can use JSP+JSTL to create a view page.
  • Front Controller — In Spring Web MVC, the DispatcherServlet class works as the Front Controller.

Advantages of Spring MVC Framework

  • Separate roles — The Spring MVC separates each role, where the model object, controller, command object, view resolver, DispatcherServlet, validator, etc. can be fulfilled by a specialized object.
  • Light-weight — It uses a light-weight servlet container to develop and deploy your application.
  • Rapid development — The Spring MVC facilitates fast and parallel development.
  • Reusable business code — Instead of creating new objects, it allows us to use the existing business objects.
  • Easy to test — In Spring, generally we create JavaBeans classes that enable you to inject test data using the setter methods.
  • Flexible Mapping — It provides specific annotations that easily redirect the page.

--

--