Skip to content

Spring MVC Overview#

Model-View-Controller (MVC)#

  • MVC stands for Model-View-Controller, which is a popular design pattern used in software engineering to separate the application's user interface (view) from the application's data (model) and logic (controller).

  • The MVC pattern separates an application into three components:

    • Model: represents the data and business logic of the application.
    • View: represents the user interface of the application.
    • Controller: handles the user input, manipulates the model, and updates the view.

What Is Spring MVC?#

  • Spring MVC is a Java framework used for developing web applications, which is built based on the MVC architectural pattern. This framework is a part of the larger Spring Framework and makes use of the features of the Core Spring Framework such as Spring Inversion Of Control (IoC) and Spring Dependency Injection (DI).

 #zoom

  • In Spring MVC, the model is represented by the application's business objects or data access objects, the view is typically implemented with JavaServer Pages (JSP), and the controller is implemented with a Java class annotated with the @Controller annotation. The front controller which is known as a Dispatcher Servlet receives the HTTP request then delegate it to the controller to process the request by invoking the appropriate service or data access object, and then returns a response to the client in the form of a view.

  • Spring MVC also provides several features such as data binding, validation, and internationalization to simplify the development of web applications. It also provides integration with other Spring frameworks such as Spring Security for implementing security, and Spring Web Services for building web services.

Why Spring MVC?#

  • The Spring way of building web app UIs in Java.
  • Leverage a set of reusable UI components.
  • Help manage application state for web requests.
  • Process form data: validation, conversion etc.
  • Flexible configuration for the view layer.

See Also#

References#