Why Spring MVC?
With so many MVC based web application frameworks available in the market, why do you need one more MVC-based web application framework?
I will try to answer this question by letting you go through Spring MVC’s brief history and its strength in this section.
To reiterate, Spring Framework was first released in June 2003 and the first release version 1.0 got released in March 2004. At that point in time the number of web application frameworks based on MVC was really very slim. Of the available MVC web application frameworks, Apache Struts led the way in quite a substantial fashion and was without any doubt market leader closely followed by so called WebWork developed by OpenSymphony. Spring Framework wanted to reinvent MVC based web application framework by realizing its own framework in the form of Spring MVC. Taking care of some of the architectural deficiencies and introducing various strengths, Spring MVC came into the market competing with the famous Struts.
Spring MVC boasts lot of benefits/strengths, of which some of them are highlighted as summarized below:
- Based on Spring Framework and uses all of its features in all aspects
- Simple, easy to understand and comprehend
- Highly flexible and extensible
- Capability to support various view technologies
- Simple but powerful tag library
Spring MVC Architecture
Spring MVC is a popular request-driven framework and the overall approach is very much similar to the famous Struts web application framework.
Spring MVC closely resembles Apache Struts in many way as you could make out with the side by side basic architecture of both Apache Struts and Spring MVC in Figure 14-2 below.
Figure 14-2. Apache Struts Vs. Spring MVC
Spring MVC forms the foundation for all the Spring web modules and comes packaged with the Spring Framework. The Spring MVC’s architecture can be pictorially represented as shown in Figure 14-3 below.
Figure 14-3. Spring MVC architecture
As shown in Figure 14-1 above, it implements the famous MVC pattern which in turn uses the “Front Controller” software design pattern. The Front Controller in Spring MVC is enacted by “DispatcherServlet”. The events happening when the Front Controller (DispatcherServlet) receives the request from the user can be summarized as below:
- The Front Controller (DispatcherServlet) which is configured in the web deployment descriptor (web.xml), receives the request from the client.
- With the help from HandlerMapping (explained in later sections), finds the appropriate Controller and invokes it.
- The Controller executes the business logic (calls a service in the business tier) and returns a ModelAndView object back to the DispatcherServlet.
- The DispatcherServlet now determines the appropriate view from the ModelAndView object.
- The DispatcherServlet now passes the model object to the selected View.
- The View is now generated and send to the DispatcherServlet, which sends the response back to the Servlet Container, which then sends the response back to the user.
Page Visitors: 7466
Latest posts by Tomcy John (see all)
- A Guide to Continuous Improvement for Architects - February 2, 2023
- Cloud-first Architecture Strategy - January 26, 2023
- Architecture Strategy and how to create One - January 24, 2023