Results 1 to 8 of 8

Thread: Why use Spring MVC ?

  1. #1

    Default Why use Spring MVC ?

    Why you recommend me to use Spring MVC for my new project?
    Tell me why ? How steep is learning curve ? If not I will be using Struts ?

  2. #2
    Join Date
    Nov 2009
    Location
    Montreal, Quebec
    Posts
    398

    Default

    If you read the documentation, you'll quickly get up to speed http://static.springsource.org/sprin...eference/html/. If you need something working quickly, try out Spring Roo which can generate most of the code behind a Spring MVC app. In my own experience, the learning curve for Spring was a lot more gentle than the learning curve for Struts.

  3. #3

    Default

    Already have ton of experience on Struts and Spring. Love Core Spring but Spring MVC is new to me? When I converted JDBC to SpringJdbc I was socked to know how easy and clean codes are. Spring MVC vs Struts i am debating for my new project.

  4. #4
    Join Date
    May 2005
    Posts
    288

    Default

    You didn't mention, if it would be Struts 1 or Struts 2. Assuming you mean Struts 1, the following advantages of Spring MVC come to my mind:
    • Stricter separation between controller and view. A lot of view technologies are already available and adapting new ones isn't really difficult.
    • Erroneous values are handled by the framework, so your command objects need to store only correct values.
    • Being able to use collections, arrays and maps in forms helps a lot when dealing with complex ones.
    • Excellent I18N support, especially, now formatters are there.
    • Interceptors (in conjunction with the strict separation between model, view and controller) allow you to extract common functionality. Much better than inheriting from a giant abstract controller class.

    One thing I will be missing though, are the provided implementations of the Controller interface. They are deprecated.

    HTH

  5. #5
    Join Date
    Aug 2010
    Posts
    7

    Default

    Having never worked with Struts I can't compare, but having learned Spring solo with no help but the internet and forums I can tell you that learning curve for Spring 3.0 is really not bad at all. Spring 2.5 on the other hand was quite a challenge. Biggest technical challenge is probably the initial setup, which as mentioned, Roo can mostly do for you.
    The emphasis on annotations, are in my opinion, very intuitive to the point that you don't need to "learn the framework" as much as use it- presuming you are familiar with MVC architecture in general.

    If however, you are looking for "fast" development and don't mind learning some Groovy syntax, you might find Grails faster and perhaps even more intuitive, as a lot is done "magically" (i.e. out of your control). But the learning curve for Groovy is (debatable) longer than the learning curve for the Spring 3.0 framework, but might payoff in terms of output.

  6. #6

    Default

    With Spring 3.0 (actually starting with 2.5 really), the learning curve for Spring MVC isn't nearly as bad. Two approaches I'd recommend just to get a feel for what Spring MVC can do
    1. Look at the Reference Doc at: http://static.springsource.org/sprin...-reference.pdf and check out chapter 15 (Web MVC).
    2. Download the STS and create a new project as New ->Spring Template Project and select Web MVC. Poke around the new project and see the various pieces.

    BTW - Just because you use Spring MVC doesn't mean you need to forget Struts. It's possible to integrate both if you have legacy projects - or maybe if you're more familiar with Struts. However, I'd recommend spending a day just poking around with Spring MVC and I think you'll be sold.

  7. #7

    Default

    What's about JSF 2.0 vs Spring MVC ?

  8. #8

    Default

    In the context of MVC, JSF is primarily focused on the 'V' portion. Spring has had support for JSF as the view technology for a while (see http://static.springsource.org/sprin...ation.html#jsf). While the current 3.0 release doesn't explicitly include support for JSF 2.0, it's still possible to use JSF 2.0 as this article outlines.
    http://www.techjava.de/topics/2010/0...reality-check/

    The key point is that with the Spring framework, you aren't locked into 100% usage of all the elements of the framework. There are three key philosophies that you'll find with the Spring framework.
    1. Where possible, avoid lock in to the framework
    2. Always use standard approches where possible - this is evidenced when standard annotations have replaced the Spring specific ones. The framework both supports and encourages use of the standard approach.
    3. Enable the most flexibility for alternative solutions - Just look at the Reference Documentation (Ch 16) on view technologies as an example

    So the point is, if you want to use other view technologies - do so. What the Spring framework offers is IoC, AOP and enterprise integration simplification. These are avilable to pick & choose from as you desire - or as your project requirements dictate.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •