View Full Version : Spring MVC Web Framework versus Struts
biguniverse
Jul 18th, 2005, 10:44 AM
I realize the benefits listed below are good reasons to go with Spring MVC over Struts but how popular is Spring MVC and how much is it actually being used out there?
I realize why Spring's IOC is popular (and I personally love the dependency injection paradigm); however, for web frameworks is it better to go with Struts at present then to take a risk using Spring MVC? I'm afraid that with sub-projects like Web Flow, the Spring MVC Web Framework might be stable but still work-in-progress (I realize webflow is built on top of Spring MVC).
Being a consultant, I'm always concerned about skill set a customer has in-house from a maintenance perspective, so I'm either considering a "Spring MVC <> Spring IoC <> Hibernate" combo or "Struts <> Spring Ioc <> Hibernate".
Any advise would be appreciated.
[BENEFITS]
1. Spring provides a very clean division between controllers, JavaBean models, and views.
2. Spring's MVC is very flexible. Unlike Struts, which forces your Action and Form objects into concrete inheritance (thus taking away your single shot at concrete inheritance in Java), Spring MVC is entirely based on interfaces. Furthermore, just about every part of the Spring MVC framework is configurable via plugging in your own interface. Of course we also provide convenience classes as an implementation option.
3. Spring, like WebWork, provides interceptors as well as controllers, making it easy to factor out behavior common to the handling of many requests.
4. Spring MVC is truly view-agnostic. You don't get pushed to use JSP if you don't want to; you can use Velocity, XLST or other view technologies. If you want to use a custom view mechanism - for example, your own templating language - you can easily implement the Spring View interface to integrate it.
5. Spring Controllers are configured via IoC like any other objects. This makes them easy to test, and beautifully integrated with other objects managed by Spring.
6. Spring MVC web tiers are typically easier to test than Struts web tiers, due to the avoidance of forced concrete inheritance and explicit dependence of controllers on the dispatcher servlet.
7. The web tier becomes a thin layer on top of a business object layer. This encourages good practice. Struts and other dedicated web frameworks leave you on your own in implementing your business objects; Spring provides an integrated framework for all tiers of your application.
Rod Johnson
Jul 19th, 2005, 01:45 AM
Some quick thoughts.
I'm afraid that with sub-projects like Web Flow, the Spring MVC Web Framework might be stable but still work-in-progress
SWF is as much of a challenge to Struts and co. as Spring MVC. It has no impact on the stability of Spring MVC.
Another point to consider: migration from Struts to Spring MVC is pretty straightforward, as Struts Actions often translate easily enough to Spring MVC Controllers.[/quote]
roadbugcz
Nov 8th, 2005, 03:37 PM
And that is status of declarative validation in Spring. I've been searching a bit and it seems there are 2 possibilities, one is jakarta commons validator and the second is Valang, both of them seem to be in the sandbox.
I'm not sure how usable/stable are these two at the moment. Have anybody used them in production? Any good/bad experience? Any informations welcomed.
Thanks a lot,
Mirek
Keith Donald
Nov 8th, 2005, 04:29 PM
To second Rod here:
Spring Web Flow (SWF) is not built on top of Spring MVC: the two framework compliment each other in a loosely coupled manner. More specifically, Spring MVC can delegate to SWF for flow execution via a thin adaption layer, and that's how it's always been designed (and will stay that way).
SWF is a pure controller framework focused primarily on solving the problem of managing stateful web conversations (dialogs) in a elegant manner, providing a self-contained flow engine based on a finite-state machine.
Spring MVC is a request-driven MVC framework positioned very much as a Struts+1, with a more complete data binding facility and more extensibility points than what's offered by Struts.
SWF fills the "C" in the MVC -- SWF is not a replacement for Spring MVC, it's a "C" compliment.
Keith
chuisman9955
Nov 8th, 2005, 06:40 PM
Spring MVC is much easier to use and maintain than struts in my opinion (I've been using struts for the past 3 years).
And that is status of declarative validation in Spring. I've been searching a bit and it seems there are 2 possibilities, one is jakarta commons validator and the second is Valang, both of them seem to be in the sandbox.
I'm not sure how usable/stable are these two at the moment. Have anybody used them in production? Any good/bad experience? Any informations welcomed.
Thanks a lot,
Mirek
I really like Valang it is quick and easy to use, although I am having problems creating a custom function (http://forum.springframework.org/showthread.php?t=19570&highlight=valang).
I need to vaidate certain things such as email addresses, zip codes, and phone numbers but out of the box this does not yet seem possible, and like I said I'm having difficulties creating a custom function.
kris_lander
Nov 9th, 2005, 10:05 AM
I'm currently using Spring MVC (with Webflow) in anger (i.e. on a commercial app) for the first time.
Most of major advantages have already been mentioned, but I have found being completely view independent very useful. It's easy to use any view technology you please. Further more it's possible to use multiple view technologies at the same time which very little hassle which has been very useful on the current project I'm working on.
Being able to declare a Controller just like any other Spring bean is also very powerful and if you use your imagination a bit there are some interesting things you can do. For example, a Spring feature I have taken advantage of with my controller declaration is being able to extend from a parent bean controller declaration. E.g.
<bean id="productsViewController" abstract="true" class="com.web.controller.ProductsViewController">
<property name="validateOnBinding" value="true"/>
<property name="commandName" value="productCriteria"/>
<property name="productServicer">
<ref bean="productServicer"/>
</property>
<property name="commandClass" value="com.web.form.ProductCriteria"/>
</bean>
<bean id="accessoriesProductViewController" parent="productsViewController">
<property name="successView" value="accessories.view"/>
<property name="productType" value="accessories"/>
</bean>
It's this sort of seamless integration with the rest of the Spring Framework that gives much more flexibility than Struts IMO.
There are only two reasons I can think for using Struts in a Spring application.
1) You have a lot of developer resources with strong Struts skills and no time to train them up on Spring MVC. (Saying that I think if they can't pick up Spring MVC quickly after using Struts you'd have to question whether you should be employing these resources in the first place!)
2) You have a lot of legacy/core code in Struts that you want to reuse.
So far my experience with Spring MVC has been very encouraging. I think the biggest indicator that it is a superior technology is that I haven't missed any functionality offered by Struts, because there has always been an equal, if not superior equivalent in Spring MVC. On top of that I have discovered many new features in Spring MVC (and even more so Webflow) that I like a lot.
If you are using Spring elsewhere in your application then I would find it very hard to think of a good technical reason to use Struts. I think most objective people consider Struts to be showing it's age, whilst Spring MVC is just getting started.
chunhui
Dec 20th, 2005, 03:11 AM
Well, putting a poll to compare Spring MVC on Spring forum isn't my idea of a fair poll., thought I'm really interested in the results. 1 vote for Spring from me! maybe we can add tapestry and other MVC frameworks to make things more interesting :)
jasonchen_nj
Feb 8th, 2006, 03:45 PM
Is there any document or book to help about this conversion?
I am in a Strus shop. We are trying to use the Strus-spring-plugin for the new project because we need to reuse our JSP tag lib and use Tiles temple to construct the page.
We also really need the spring web flow type of controller to deal with our new page flow states requirements.
Any tip will be much appreciated.
Colin Sampaleanu
Feb 10th, 2006, 10:00 AM
There are a number of books which contain some material about Spring MVC, including Professional Java Development with Spring, Pro Spring, Spring in Action, and Spring Live.
There are no books which contain material on SWF at this time, but Expert Spring MVC and Web Flow (http://www.apress.com/book/bookDisplay.html?bID=10048) should be shipping in a few months.
Regards,
Colin Yates
Feb 10th, 2006, 10:15 AM
There are no books which contain material on SWF at this time, but Expert Spring MVC and Web Flow (http://www.apress.com/book/bookDisplay.html?bID=10048) should be shipping in a few months.
Don't quote me on this, but check the shops at the end of this month ;)
puffybsd
Feb 12th, 2006, 07:06 PM
I was quite happy working with SpringMVC, and now that I'm working with struts, I have to say that you would not be doing anyone any favors by choosing struts over SpringMVC.
Forget about leveraging existing skills, because struts developers will catch on quickly and save a lot of time not having to deal with ActionForms or wiring up their struts components to play correctly with the spring container. From my experience, developers unfamiliar with either pick up on SpringMVC much faster than Struts. As mentioned above, switching should be pretty easy, but once you do, you'll kick yourself for the time wasted. Tiles should not be an issue, because it should work without struts.
A more compelling question is whether to choose WebWork, Echo2, openlaszlo(+SpringMVC), tapestry or jsf, or better yet, what are the associated costs of migrating to one of these later if the opportunity presents itself.
chuisman9955
Feb 13th, 2006, 03:57 PM
I'd like to hear if anybody has succesfully and easily integrated spring with wicket? Wicket looks interesting, but the spring support seems lacking.
shahzad992
Feb 16th, 2006, 04:31 AM
Hi,
My question is for Mr. Rod. I have seen the schedule of Spring training programs in different countries. I belongs to Pakistan, which is now a big market of software development. And people here using spring, very few in numbers. i have used spring web mvc in my two projects and now going to use Spring Web Flow. i found spring very easy and cool. You should think about the training session for Pakistan. Is there any program of doing so?
Regards,
Shahzad
rprabhakar
Oct 6th, 2006, 07:26 PM
Is there any document or book to help about this conversion?
I am in a Strus shop. We are trying to use the Strus-spring-plugin for the new project because we need to reuse our JSP tag lib and use Tiles temple to construct the page.
We also really need the spring web flow type of controller to deal with our new page flow states requirements.
Any tip will be much appreciated.
http://opensource.atlassian.com/confluence/spring/display/DISC/Guide+to+Porting+From+Struts+to+Spring
http://www.devx.com/Java/Article/29208/0/page/4
rprabhakar
Oct 6th, 2006, 07:32 PM
And that is status of declarative validation in Spring. I've been searching a bit and it seems there are 2 possibilities, one is jakarta commons validator and the second is Valang, both of them seem to be in the sandbox.
I'm not sure how usable/stable are these two at the moment. Have anybody used them in production? Any good/bad experience? Any informations welcomed.
Thanks a lot,
Mirek
Hi
I had a similar question in my mind two months ago and the final choice that came out was Spring Modules. I got it implemented to my application and is working very well.
puchacz
Oct 26th, 2006, 05:18 AM
I have a little question. I have been searching for compare Spring, JSF and Struts Framework. I am interesting in MVC comparing in those Frameworks. Maybe some of You know where can I find such a document with those information.
Thanks
cyrille37
Jan 9th, 2007, 08:14 PM
I vote for Tapestry.
I'm using Tapestry 4.1.
Cheers, Cyrille.
tschneider
Jan 9th, 2007, 10:23 PM
First of all, struts 2.x is a completely different animal than struts 1.x. Struts 2.x is based on Webwork 2.2.x. See http://www.oreillynet.com/onjava/blog/2006/10/my_history_of_struts_2.html for details.
Several months ago, I was involved in an effort at my company to switch from an in-house web framework to an open source one. We evaluated Struts 1.x, Webwork, Spring MVC. I was really impressed with Webwork and since it was becoming Struts 2.x, we felt it had a real future. I thought that Spring MVC was better than Struts 1.x, but both were inferior to Webwork.
We also needed a workflow solution. This is where Spring Webflow came in. I really liked it, but there wasn't any real solid integration for Webwork at the time... so I wrote an integration module. :)
http://wiki.opensymphony.com/display/WW/Spring+Webflow
To me, Webwork with Spring Webflow has worked out really well. Spring as a middle tier also meshes really well with Webwork. I also believe that Struts 2.x will become pretty popular over the next year. It started with a really solid framework and is only getting better. I have a hard time understanding how Spring MVC expects to compete against JSF (Seam) and Struts 2.x. I'm not not knocking Spring MVC, it was a significant step forward when it was created, but it would need a significant architecture change to truly keep up with some of the other technologies out there.
Of course this is just my opinion, personal bias not withstanding and I'm sure the Spring guys have other thoughts on the matter. :)
andree
Apr 26th, 2007, 11:38 AM
hi,
Keith writes that Spring MVC has more extensibility points. Is there someone who could give a short sum about which extensibility points are given by Spring MVC?
thx
andree
To second Rod here:
Spring Web Flow (SWF) is not built on top of Spring MVC: the two framework compliment each other in a loosely coupled manner. More specifically, Spring MVC can delegate to SWF for flow execution via a thin adaption layer, and that's how it's always been designed (and will stay that way).
SWF is a pure controller framework focused primarily on solving the problem of managing stateful web conversations (dialogs) in a elegant manner, providing a self-contained flow engine based on a finite-state machine.
Spring MVC is a request-driven MVC framework positioned very much as a Struts+1, with a more complete data binding facility and more extensibility points than what's offered by Struts.
SWF fills the "C" in the MVC -- SWF is not a replacement for Spring MVC, it's a "C" compliment.
Keith
klr8
Apr 26th, 2007, 01:00 PM
Check the Reference documentation for Spring MVC:
http://static.springframework.org/spring/docs/2.0.x/reference/mvc.html
It discusses things like HandlerMappings, HandlerInterceptors, ViewResolvers, ...
Erwin
andree
Apr 26th, 2007, 01:25 PM
Thanks :) ok I read the reference for Spring MVC.
So if I do not misunderstand the reference it means
that:
1. you can suit in some way the workflow of the DispatcherServlet
namely when declaring some special beans used by that dispatcher
(showed in table 13.1.)
2. that you can nearly extend and suit everything in Spring MVC
from high till low level parts of Spring MVC because it is based
on interfaces what is very flexible and you can change the standard
implementation by referencing to your own implementation of that
interfaces (in the WebApplicationContext and ApplicationContext
or the web.xml).
Is it correct?
dr_pompeii
Apr 26th, 2007, 01:50 PM
First of all, struts 2.x is a completely different animal than struts 1.x. Struts 2.x is based on Webwork 2.2.x
is this a suicide???, :rolleyes:
why change the sintaxis???
http://struts.apache.org/2.0.6/docs/home.html
read again tuttorials, maybe buy a book,
think this is waste of time, i cant see a good reason
Expert Spring MVC and Web Flow
good book, i read all, but is out of date for SWF, but i can suggest: buy the book :)
spring mvc and SWF a powerful combination, make easier your life
a good question could be,
what thing you not like about springmvc/SWF ???
i am happy with both, but i dont like the pretty hell with integration springmvc and jasperreprots for example
regards and thanks for the developers for this beautiful product :D
nice job guys!!!
klr8
Apr 27th, 2007, 02:11 AM
Is it correct?
That's a pretty accurate summary.
Erwin
dxxvi
Apr 27th, 2007, 02:50 PM
I prefer JSF than Struts (both 1.x and 2.x) and SpringMVC, especially when it is used with Facelets, Ajax4jsf, some third party JSF components (like RichFaces which is still lack of some common components such as calendar, file upload, ...) and Spring Web Flow (although I cannot find any document about using SWF 1.0.3 with Ajax4jsf. Hope things will be better with SWF 1.1).
Arno Werr
Apr 27th, 2007, 07:06 PM
As long as we have JSF, I think here should be an option for JBoss Seams.
Not that I like that IMHO 'marketacture' framework, but some folks do and it would be interesting to see some preliminary statistics.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.