Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Why not Spring framework?

I've read numerous articles about the Spring MVC framework, and I still can't see the benefits of using it. It looks like writing even a simple application with it requires creating a big hodgepodge of XML files and annotations and other reams of code to conform to what the framework wants, a whole bunch of moving parts to accomplish a simple single task.

Any time I look at a Spring example, I can see how I can write something with the same functionality using a simple servlet and template engine (e.g. FreeMarker, StringTemplate), in half the lines of code and little or no XML files and other artifacts. Just grab the data from the session and request, call the application domain objects if necessary, pass the results to the template engine to generate the resulting web page, done.

What am I missing? Can you describe even one example of something that is actually made simpler with Spring than using a combination of raw servlets with a template engine? Or is Spring MVC just one of those overly complicated things that people use only because their boss tells them to use it?

EDIT: A summarized concrete description would be helpful. For example, "I used Spring MVC to build an application that did XYZ, and its feature Q saved me from having to do the extra work of A and B and C which would have been necessary with raw servlets and a template engine." Simply mentioning marketing buzzwords like "dependency injection" doesn't clarify anything.

share|improve this question

marked as duplicate by ChrisF Jun 30 '12 at 22:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

you might be missing the concept of MVC pattern. – Yusubov Jun 30 '12 at 19:06
@Yusubov You can have MVC with raw servlets. The servlets ARE the controllers. With annotations, you can use servlets just like you would use a controller. – stepanian Aug 2 '14 at 5:44
  • dependency injection (you need this for unit tests)
  • easy to define request mappings makes creating a restful api possible in mins
  • custom jsp tags
  • jdbcTemplate
  • an enourmous library of useful functions (eg security, internationalization, device interceptor etc etc)

Is just a few of the practical benefits you can get off the top of my head. Its sheer size can be offputting, and the config is somewhat confusing to begin with, and still cause sme problems now and again (after two years).

Yes it promotes to model-view-controller, controllers are so much nicer to write than vanilla servlets (less verbose, more powerful).

It has a learning curve, once that has been passed you can definitely be more productive with spring, than without, imho.

share|improve this answer
I like Spring's JDBC library, but it is separate from MVC, as is internationalization etc. For the rest, those are theoretical benefits I've seen listed but no example of how it actually makes anything simpler. – Gigatron Jun 30 '12 at 21:53
it appears you have made your mind up and ignored the specific mvc examples I also included. It might be worth checking out some examples – NimChimpsky Jun 30 '12 at 22:12
My mind is not made up; I'm trying really hard to see the benefit of Spring MVC. But for every example I see, the Spring way is more complicated than servlets + template engine. – Gigatron Jun 30 '12 at 22:25
@Gigatron I agree. You can build a basic web app using servlets in the same amount of time as Spring or even less. – stepanian Aug 2 '14 at 5:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.