12 BENEFITS of Spring MVC over Struts

Spring is a powerful Java application framework, used in a wide range of Java applications. It provides enterprise services to Plain Old Java Objects (POJOs). Spring uses dependency injection to achieve simplification and increase testability.

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.

8. No ActionForms. Bind directly to domain objects

9. More testable code (validation has no dependency on Servlet API)

10. Struts imposes dependencies on your Controllers (they must extend a Struts class), Spring doesn’t force you to do this although there are convenience Controller implementations that you can choose to extend.

11. Spring has a well defined interface to business layer

12. Spring offers better integration with view technologies other than JSP (Velocity / XSLT / FreeMarker / XL etc.)

Reference: Here

44 thoughts on “12 BENEFITS of Spring MVC over Struts

  1. Hi Lijin,

    I face one problem while hosting my application.

    the following may be the problem.

    If we place these two (xml-apis.jar, XercesImpl.jar) jar files in tomcat folder (X:\my_app\Portal\tomcat\common\endorsed), it will give the problem (Provider org.apache.xalan.processor.TransformerFactoryImpl not found).

    If we remove these two jar files system may work fine(Tested in local system only).

    Now i am unable to remove file in server,
    There is any other alternate way to do that one.

    Thanks in advance,
    Mohan

  2. Yea sure frnd. I will recommend you the first option. Spring is an application framework and it handles Hibernate very effectively. Spring makes hibernate codes very very simple.

    But In struts I think there is no supporting classes for hibernate because it is not an application framework. I am not an expert in this Struts… but I highly going for the Spring- Hibernate option.

  3. Hi Lijin,

    i have to create application which should support minimum 2 lakhs online user at a given time.The application is similiar to dating application.

    for this i am going to use Tomcat server bec this is free one(client too need this).

    Now my problem is whether i can go with
    Spring with Hibernate
    (or)
    Struts with Hibernate

    is it Hibernate support this much of user?

    Thanks in advance

  4. Hi Lijin

    It’s me again :). Right now I would like to give You another question (of course if I can ).

    The question is this point:
    “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.”

    I know how easy is to use another then JSP view in Spring, because I did it :), but could You tell me how this situtation looks in Struts? I can’t find any information about this. Which of views can I integrate with Struts and is this very complicated?

    Thankx

  5. Sorry for the delay martin..:) For the last two days i was really busy …..

    I haven’t tried out JSF yet. But I can surely give some directions to make a judgment between struts and spring MVC. Unlike Struts, Spring uses IoC to inject the dependencies to the code. Spring also promote best practices of interface implementation separation and its assembly via spring context files. Thus Spring provides a pluggable configuration and a very clear separation between controllers, JavaBean models, and views. In struts the dependencies are hard coded as in any java program introducing coupling in various part of the program.

    Another major difference is that Spring is an application framework unlike the struts which is just an MVC that operated at the presentation tier. Spring provides support for all the tiers of the application including the presentation tier, business tier and the data access tier. Spring manages its business objects in a non-intrusive way (ie. it does not have any dependencies with the domain layer). It again resolves its dependencies via dependency injection and IoC.

    Best of luck for ur project 🙂

  6. Hi

    At first a would like to tell You that I like You article about “12 BENEFITS of Spring MVC over Struts” very much. It is helping me in my homework a lot (I am a student
    who writes a little project about framework ). But I have a few questions coresponding to this article.

    What did You mean when You said: “Spring provides a very clean division between controllers, JavaBean models, and views.” Why do You think so? And could You give the
    example of this, please? (* I know what the MVC is)

    You also said that “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.”. How it is done in Struts?

    And the last think “11. Spring has a well defined interface to business layer”. Where do You see the problem in Struts (example).

    I also have a quastion if You could tell what “bad” or “good” things do You see in JSF coresponding to Spring and Strus?

    Thanx
    Martin

Leave a reply to martin Cancel reply

Design a site like this with WordPress.com
Get started