Spring vs Struts 2.0

While creating J2EE applications, it needs to be decided some times which technology we should go for – Struts or Spring. This is some points comparison between Spring and Struts.

1. In most of the key features compared, Spring MVC and Struts 2 are equally good, except in the UI supports. It seems to me Spring MVC just provides tags for basic HTML form tags while Struts/WebWork 2 provides many out-of-box JSF-styled complex and composite tags, such as:
a) Struts 2 integrates with Dojo AJAX framework closely and provides many complex UI components out-of-box, such as datepicker, tooltips, etc.
b) Struts 2 has AJAX theme.
c) Struts 2 tags are stylesheet-driven, making it easier to develop consistent pages.
d) Struts 2 checkboxes are stateful, and require no special handling.
The recent release of Spring 2.0 does not seem to have any work on this area.

2. 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.

3. Struts has been around a long time and has been popular for years – there’s a wealth of knowledge about it in the user community and more literature around

4. If you want a bunch of taglibs that generate form fields and so forth, Struts is probably the better choice.

5. 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. We didn?t have that problem .

6. Spring does not present a framework for implementing business/domain logic. It helps you create a Controller and a View for your application, no Model though. Spring is a fully fledged application framework, that has a large stack of sub projects.

7. As for spring, if we look at its history, it started as an effort for supplying a solution for enterprise java applications, and to replace EJBs (while it also provided integration with EJBs for people who didn’t want to ditch that). Spring is much more than an MVC framework. It provides dependency injection, AOP, integration with almost every known framework, a security framework (a separate sub-project), and a lot of other stuff. Struts 2 and hibernate integrate easily with spring, so you might like to add it to your stack, without ditching struts 2
8. If you’re going to use Spring for other middleware services, and you have no Struts expertise in house, then it would be simplest to go with SpringMVC. If you know Struts well or have team members who do, or you already have a Struts project, it may make sense to stick with it.

So, basically, it depends on the requirements and the resources what and how you want to achieve which will decide what is to be used, Stuts 2.0 or Spring.

About Sanju
I am Software Programmer. I am working in JAVA/J2EE Technologies.

One Response to Spring vs Struts 2.0

  1. Hi , thanks for giving differance btween strut 2 and spring. Currently i am referring some tutorials on spring on web . i want to know that spring validation framework is better than strut 2 ‘s validation fw or not .. if yes then how ????

Leave a comment