In this example we will give you quick overview of Spring MVC Framework. The Spring MVC framework is the MVC stack for the development of web applications based Model View Controller (MVC) architecture.
What is MVC architecture?
The MVC or Model View Controller architecture is famous design pattern used in designing the applications. This design pattern separates the application into three parts called Model, View and Controller.
Model: Model is the business data or simple the data of the application.
View: View is the presentation part of the application such as data entry form, reports etc.
Controller: The controller component delegates between Model and view.
The Spring Framework is light-weight container and it supports multiple frameworks and libraries. The Spring framework allows the developers to mix and match multiple frameworks while developing and deploying the applications. The Spring MVC takes the advantage of Spring framework and provides once to best and productive framework for development of web applications.
The Spring MVC is a web development framework based on the MVC (Model View Controller) design pattern. The features of Spring MVC framework are the Pluggable View technology and Injection of services into controllers. Let's see in detail:
Pluggable View technology
There are many view technologies such as JSP, Tiles, Velocity etc. Spring framework allows us to use these view technologies.
Injection of services into controllers
The IoC container provides the important functionality of the dependency injection. This helps the programmer to inject the dependency such as business service at runtime. This saves lot of code duplication and coding effort.
Spring's MVC components:
The class org.springframework.ui.ModelMap is used by the spring framework to hold the data. It wraps the business data into org.springframework.ui.ModelMap class and then pass it to the view.
Framework provides pluggable view, and it allows the developers to create views using jsp, Velocity and Jasper templates. In Spring MVC Logical view and Model are represented in the object of the class org.springframework.web.servlet.ModelAndView.
The controller is responsible for handling all the requests from the user and then process the user request. Here are the list of controllers available in the Spring 2.5 framework:
In the next sections we will see the examples of all these controllers.
Liked it! Share this Tutorial