Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this questionDoes anyone know difference between Struts2 and Spring 3 MVC. I know the difference between Struts 1 and Spring 2.5, but what's the advantage Struts2 has over Spring 3 or otherwise.
I tried looking all over web, but there is no comprehensive answer anywhere.
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 doesn't always throw out their own code base to start anew when they issue a sequel.
That said, I'm 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 Raible's 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
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 COMPARINGStruts 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)
I would answer in a opinionated way as I have not used spring MVC much.
Use struts2 for
1)struts2 tags and
2)struts 2 plugins and
3)struts2 plugin framework using freemarker makes struts2-jquery-plugin and config-browser-plugin
The struts 2 convention allows you to create action class without even annotations and zero configuration in xml. Its just to make it look good in paper however in all real big projects you will need to write annotations. If you get lost among annotations during runtime there is a way to find out the configuration in browser in dev mode, try config-browser-plugin.
Remember Struts/spring MVC consists of a very small part of a web application only upto the front controller.
Not to be snide, but if it's worth your time to consider a framework choice, then it's also worth your time to stand up some spikes against you most important couple of high level user stories. Both Struts2 and Spring MVC 3 have very easily set up demo enviroments, i.e. you can get a maven archetype running out of your IDE in less than 5 minutes.
I've been involved in panel discussions about which framework is better, and I truly believe that no amount of discussion is worth the time. You're much better served by playing with the frameworks in the context of your use cases.
If you know the difference between struts 1 and spring 2.5, ask yourself instead what difference there is between struts 1 and 2, and spring 2.5 and 3 respectively. In the latter, there's the refinement of webmvc with validation, xml marshalling, rest etc. See What's New in Spring 3.0, for struts see What's new in Struts 2.0.
As Umesh said, Positive side of spring3 MVC is that it has deep integration with Spring. In one of my project, I was using proprietary DI framework so Struts2 was obvious choice ( we didn't wanted two DI framework together)
Struts2 is matured and widely used web-framework with very active community support. Spring3 is big framework with many modules including spring mvc.
Struts 2 has suffered from a number of security vulnerabilities in the last two years and this fact should be considered. http://www.cvedetails.com/product/6117/Apache-Struts.html?vendor_id=45
http://www.cvedetails.com/vendor/9664/Springsource.html
精彩评论