Difference between Struts and Spring

1. Struts is a web framework only, Struts can be compare with the SpringMVC. And SpringMVC is subset of the Spring framework. So we can say that Sturts can be seen as the subset of the spring framework in functionality point of view.

2. What Action class do in struts, Controller does in Spring. And action in Struts is a Abstract class but Controller in Spring is an interface, This is very good advantage of the spring.

3. Spring don't have any action from, it bind the http form values directly into pojo. Instead of initializing the form bean spring directly initialize the domain object.

4. ActionForward in struts is replace with the ModelAndView in Spring. Model component contain the business object to be displayed via view component.
Spring has excellent support classes for jdbc. Classes like MappingSqlQuery, SqlUpdate, StoredProcedure help you manage the selects,inserts and stored procedures. With Spring you need not even have try, catch and finally in your jdbc code. Spring handles opening, transaction management and closing of connections. When it comes to designing your application i would say that integrating struts with Spring gives you quite a few options. Struts for the view and control, Spring for the jdbc part.

5. Unlike Struts Spring don't provide any separate tag library.
6.Struts implement MVC Design Patten where as Spring implements IOC Design Pattren and addreses AOP Cross cutting concerns.

7.Struts is heavy weight where as Spring is light weight framework.

8.Struts is tightly coupled Spring is loosely coupled.

Struts will be Generally used as a Front End Frame work.
Spring has spring webFlow for the same purpose, which is part of spring Framework.
The other major advatages of spring Framework is it handles
- Transaction management
- support for Messaging
- support and Integration with Other Frame works.
(Eg: Hibernate, Struts, Tapestry.. etc)
Struts Framework have some advantages
-Excellent support for Tag Library, which has wide industry acceptance.
-Easy to integare with other client side technologies.

Struts2 because it is relly flexible and extendible with Plugins.

1.) Convention Plugin
No more XML Hell!

2.) REST Plugin
Support for REST based URLs and Applications

3.) Getter/Setter for Parameter

4.) jQuery Plugin :-)

5.) JSON Plugin

-----------------------------------------------------------------------

Difference between struts and springs could be analysed from various facets.

(1) Purpose of each framework.
(2) Various feature offerings at framework level.
(3) The design & stuff.

Firstly, Struts is a sophisticated framework offering the easy 2 develop, structured view/presentation layer of the MVC applications. Advanced, robust and scalable view framework underpinning reuse and seperation of concerns to certain extent. Springs is a Lightweight Inversion of Control and Aspect Oriented Container Framework. Every work in the last sentence carry the true purpose of the Spring framework. It is just not a framework to integrate / plug in at the presentation layer. It is much more to that. It is adaptible and easy to run light weight applications, it provides a framework to integrate OR mapping, JDBC etc., Infact Struts can be used as the presentation tier in Spring.

Secondly, Springs features strictly associate with presentation stuff. It offers Tiles to bring in reuse at presentation level. It offers Modules allowing the application presentation to segregate into various modules giving more modularity there by allowing each module to have its own Custom/Default Request Processor. Spring provides Aspect Oriented programming, it also solves the seperation of concerns at a much bigger level. It allows the programmer to add the features (transactions, security, database connectivity components, logging components) etc., at the declaration level. Spring framework takes the responsibility of supplying the input parameters required for the method contracts at runtime reducing the coupling between various modules by a method called dependency injection / Inversion of Control.

Thirdly, Struts is developed with a Front Controller and dispatcher pattern. Where in all the requests go to the ActionServlet thereby routed to the module specific Request Processor which then loads the associated Form Beans, perform validations and then handovers the control to the appropriate Action class with the help of the action mapping specified in Struts-config.xml file. On the other hand, spring does not route the request in a specific way like this, rather it allows to you to design in your own way however in allowing to exploit the power of framework, it allows you to use the Aspect Oriented Programming and Inversion of Control in a great way with great deal of declarative programming with the XML. Commons framework can be integrated to leverage the validation in spring framework too. Morethan this, it provides all features like JDBC connectivity, OR Mapping etc., just to develop & run your applications on the top of this

Differences:
1)Struts is a web framework while Spring is not.
2)Spring is a Layered Architecture while Struts is not.
3)Struts is heavy weight while Spring is light weight.
4)Struts supports tag Library while Spring does not.
5)Spring is loosely coupled while Struts is tightly coupled.
6)Spring provides easy integration with ORM technologies while in struts, we need to do coding manually.
7)Struts easily integrate with other client side technologies. It is not easy in case of spring.

-------------------------------------------------------------

  1. Spring
  2. Struts
  3. Struts 2
  4. Hibernate
  5. JavaServer Faces
  6. JavaServer Pages
  7. Tapestry
  1. Spring is an IoC container (at least the core of Spring) and is used to wire things using dependency injection. Spring provides additional services like transaction management and seamless integration of various other technologies.
  2. Struts is an action-based presentation framework (but don't use it for a new development).
  3. Struts 2 is an action-based presentation framework, the version 2 of the above (created from a merge of WebWork with Struts).
  4. Hibernate is an object-relational mapping tool, a persistence framework.
  5. JavaServer Faces is component-based presentation framework.
  6. JavaServer Pages is a view technology used by all mentioned presentation framework for the view.
  7. Tapestry is another component-based presentation framework.
So, to summarize:
  • Struts 2, JSF, Tapestry (and Wicket, Spring MVC, Stripes) are presentation frameworks. If you use one of them, you don't use another.
  • Hibernate is a persistence framework and is used to persist Java objects in a relational database.
  • Spring can be used to wire all this together and to provide declarative transaction management.
I don't want to make things more confusing but note that Java EE 6 provides modern, standardized and very nice equivalent of the above frameworks: JSF 2.0 and Facelets for the presentation, JPA 2.0 for the persistence, Dependency Injection, etc. For a new development, this is IMO a serious option, Java EE 6 is a great stack.

--------------------------------------

Struts framework is a mvc pattern. spring framework is a mvc pattern and other patterns also include in this.
STRUTS :
1.Struts framework is based on MVC pattern to develop web
applications and which is used to generate integration logic
dynamically.
2.Struts allows only JSP as a view component.
SPRING:
1.Spring framework is used to develop enterprise applications.
2.Spring framework not only allows JSPs but also other views
such as Velocity,Freemaker etc.,
3.Spring f/w consists of 6 modules which are alternatives
for existing J2ee Technologies.

If you enjoyed this article, you might also like..