java – Struts2 vs Spring 3

java – Struts2 vs Spring 3

Struts2 is really WebWork 2 renamed as Struts2. Consider for a moment the fact that Struts essentially leveraged its own brand name to adopt WebWork as its new base, and that should suggest to you that there was at least some who felt it was very compelling — one doesnt always throw out their own code base to start anew when they issue a sequel.

That said, Im not going to tell you that Struts2 is better/worse than Spring 3 MVC. Bottom line is that they are definitely comparable.

If you want more details on how they compare, I suggest you check out Matt Raibles presentations in years past on this topic:

http://raibledesigns.com/rd/entry/my_comparing_jvm_web_frameworks

http://static.raibledesigns.com/repository/presentations/ComparingJavaWebFrameworks-ApacheConUS2007.pdf

including a spreadsheet that compares several of them on various degrees:

http://spreadsheets.google.com/pub?key=0AtkkDCT2WDMXdC1HOEtnUHpCejJMbUhGeGJWUmh5dVE&hl=en&output=html

Well Both Struts2 and Spring3 are very much similar in many respects.Both are action oriented framework and much same in the flow.Spring MVC came out due to all known limitations of Struts1.
but when you come to choose Struts2 vs Spring3 MVC there is not much you can differentiate and both are well designed and good framework.
for Struts2 as its webwork based framework but with lots of improvements over webwork.one major advantage is UI tags support for Struts2
regarding spring3 mvc its equally good and powerfull positive side is its well and very deep integration with Spring framework.

We are using Struts2 with Spring DI and transcation management in our few projects and in some using Spring MVC.
it only matters you choice and your brand inclination.

edit

In my opinion its not a good practice to compare like designed framework,better come up with your requirements what exactly are the requirements of your project than do a analysis which framework provides best and very similar requirements as per your needs rather than doing a plain comparasion

java – Struts2 vs Spring 3

FEATURES COMPARING

Struts 2

  • Configurable MVC components, which are stored in struts.xml file. If you want to change anything, you can easily do it in the xml file.

  • POJO based actions. Struts 2 action class is Plain Old Java Object, which prevents developers to implement any interface or inherit any
    class.

  • Support for Ajax, which is used to make asynchronous request. It only sends needed field data rather than providing unnecessary
    information, which at the end improves the performance.

  • Support for integration with Hibernate, Spring, Tiles and so on.

  • Whether you want to use JSP, freemarker, velocity or anything else, you can use different kinds of result types in Struts 2.

  • You can also leverage from various tags like UI tags, Data tags, control tags and more.

  • Brings ample support for theme and template. Struts 2 supports three different kinds of themes including xhtml, simple and
    css_xhtml.

Spring MVC

  • Neat and clear separation of roles. Whether it is controller, command object, form object or anything else, it can be easily
    fulfilled with the help of a specialized object.

  • Leverage from the adaptability, non-intrusiveness and flexibility with the help of controller method signature.

  • Now use existing business objects as command or form object rather than duplicating them to extend the specific framework base class.

  • Customizable binding and validation will enable manual parsing and conversion to business objects rather than using conventional string.

  • Flexible mode transfer enables easy integration with the latest technology.

  • Customizable locale and theme resolution, support for JSPs with or without Spring tag library for JSTL and so on.

  • Leverage from the simle, but powerful JSP tag library known as Spring tag library. It provides support for various features like data
    binding and themes.


    BENEFITS COMPARING

Struts 2

  • Simplified design

  • Ease of using plug-in

  • Simplified ActionForm & annotations

  • Far better tag features

  • OGNL integration

  • AJAX Support

Spring MVC

  • Clear separation between controllers, JavaBeans models and views that is not possible in Struts.

  • Spring MVC is more flexible as compared to the Struts.

  • Spring can be used with different platforms like Velocity, XLST or various other view technologies.

  • There is nothing like ActionForm in Spring, but binds directly to the domain objects.

  • Code is also more testable as compared to the Struts.

  • It is a complete J2EE framework comprising of seven independent layers, which simplifies integration with other frameworks.

  • It doesn’t provide a framework for implementing the business domain and logic, which helps developers create a controller and a view for
    the application.

(Source http://www.cygnet-infotech.com/blog/struts-2-vs-springmvc)

Leave a Reply

Your email address will not be published. Required fields are marked *