Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Difference between Struts and Spring

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.
Struts 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.
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.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.
Struts 2 integrates with Dojo AJAX framework closely and provides many complex UI components out-of-box, such as datepicker, tooltips, etc.Spring is not.
Struts 2 has AJAX theme.Spring has not.
Struts 2 tags are stylesheet-driven, making it easier to develop consistent pages.Spring is not.
Struts 2 checkboxes are stateful, and require no special handling.Spring is not.
Struts is mainly a presentation layer framework, like redirecting to a particular page ,doing client side validations etc which otherwise very tedious using jsp and servlets.Spring is a complete J2EE framework having seven independent layers which can be used all together or few layers integrated with some other framework. Spring provides declarative transaction management and AOP. One layer of spring is for presentation purpose like struts but for only presentation layer, struts is better than spring.
If you want a bunch of taglibs that generate form fields and so forth, Struts is probably the better choice.Whereas Spring is not in this area.
Our UI is mostly click-driven and light on data and validation. It seems to me that most people run into difficulties with Struts when they start moving a lot of data from HTTP into the model.In Spring this problem does not exist.
Is it helpful? Yes No

Get differences from below

©2021 WithoutBook