Struts vs Spring MVC
Struts framework is one of the initial web application frameworks for developing Java EE web applications. Spring is an open source application framework. Some time after the introduction of Spring framework, the developers added an MVC framework to the Spring framework, hoping to address some of the limitations they perceived in Struts. But few years later, Struts2 (or Struts version 2) arrived, and it was completely different and highly improved web application framework. Now, both Struts and Spring MVC are being used very heavily for developing Java EE applications in the world.
What is Struts?
Struts (also known as Apache Struts) is a cross-platform open source framework written in Java, which is intended for developing Java EE web applications. Struts encourage the usage of MVC (Model-View-Controller) architecture. It is an extension of Java Servlet API. Craig McClanahan is the original creator of Struts. Initially it was known as Jakaratha Struts, and was maintained under Jakarta Project of Apache Software Foundation. Its current stable release is version 2.2.3, which was released in May, 2011. It is released under Apache License 2.0. Struts framework is called a request-based framework, and it is made up of three main components: a request handler, a response handler, and a tag library. Standard URI (Uniform Resource Identifier) is mapped to a request handler. Response handler is responsible for transferring control. To create interactive applications with forms, the features offered by the tag library can be utilized. Struts support REST applications and various technologies like SOAP, AJAX, etc.
What is Spring MVC?
Spring is an open source application framework. It was developed by Rod Johnson,, and the first version was released in 2004. Spring 3.0.5 is the current version of the Spring framework. It is licensed under Apache 2.0 license. Any Java application can use the core features of the Spring framework. There are several modules in Spring framework, and MVC is one of them. The Spring MVC framework was not a part of their original plan. In fact, the reason that Spring developers came up with their own MVC framework was to provide solutions to what they showed as deficiencies in the Struts (version 1) and other similar frameworks. In particular, they said that they wanted to address the lack of separation between the presentation layer, request handling layer, and the model. Spring MVC is also a request-based web application framework.
What is the difference between Struts and Spring MVC?
Although Spring MVC and Struts are two popular web application frameworks used for developing Java EE web applications, they have their differences. In fact, Spring MVC was developed in order to address few limitations in Struts (version 1). But Struts2 is a highly improved framework than version 1 (they don’t even share the same code base), and therefore, the Spring MVC and Structs2 are highly comparable.
One of the main advantages of Spring MVC is that it is possible to have seamless integration with many view options such as JSP/JSTL, Tiles, FreeMaker, Excel, PDF and JSON. But, unlike Struts, Spring MVC does not provide built-in AJAX support (need to use third-party AJAX library).
Ultimately, both of them are considered highly mature frameworks, and choosing between the two comes down to the personal preference. It is important to note here that if there are any negative feelings towards struts, they are only due to the deficiencies that were found in Struts version 1 (which is now considered obsolete).