BT

Article: Spring 2.5: New Features in Spring MVC

by Geoffrey Wiseman on Aug 13, 2008 |
Rossen Stoyanchev of SpringSource wrote Spring 2.5: New Features in Spring MVC for InfoQ about the new features in Spring MVC that are part of Spring 2.5, notably the annotation-based approaches that are informally known as @MVC.  These allow Spring MVC applications to be written with simpler annotated POJOs rather than xml-wired implementations of strict interfaces.  For instance, in describing the changes to a Spring MVC controller under @MVC, Rossen highlights these differences:
  1. It does not have any interface or base class requirements.
  2. It allows any number of request handling methods.
  3. It allows a high degree of flexibility in the method's signature.
The article continues to discuss the flexible method signatures, request mapping, parameter handling, implicit url-mapping, form processing and data binding. 

Rossen's article follows Mark Fisher's article What's New in Spring 2.5: Part I about the simplified configuration and annotation-based functionality in the core spring context.

Hello stranger!

You need to Register an InfoQ account or to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Using Spring @MVC for REST services by Terence Ingram

I have been using Spring MVC for my rest services. I have been very happy with using it.

I chose this as I was using hibernate and I really like the @Transactional annotation :) When @MVC was released I easily upgraded my old services. I am quite happy with it.

But I am hoping that the Spring crew get more serious about REST and enhance @MVC to fully support REST. I have some suggestions that would make it easier: enhance the @RequestMapping annotation to be more like the @Path annotation as used in javax.ws.rs.Path. What I am looking for is the ability to break up the URL easily i.e. @RequestMapping("/accounts/{id}/details") where I can then reference id as an instance variable in my code having the value populated. Also automatic WADL support would be nice. This is not essential but would save me the hassle of doing it by hand.

Re: Using Spring @MVC for REST services by Ray Krueger

Yes! I completely agree with Terence above. The @MVC project is simply incomplete without support for REST style urls EX: @RequestMapping("/accounts/{id}"). Continuing to rely solely on request parameter binding is not what the world wants to do these days. The JAXRS stuff is a kind of a pain in the ass to use (especially if you like Spring) and this is where Spring could really help out :)

Re: Using Spring @MVC for REST services by Dmitriy Kopylenko

"True" REST support should be upcoming in Spring 3: www.springify.com/archives/16

Re: Using Spring @MVC for REST services by Geoffrey Wiseman

Yes, looking forward to seeing how this comes about -- getting good RESTful URLs into a Spring MVC application will be great, although it'd also be nice to see some collaboration with JAX-RS if you're doing RESTful web services in addition to RESTful URLs in your web application.

This was one of the first questions that came to my mind looking over the parameter handling and url mapping in Spring MVC as well.

Link needed by Colin Sampaleanu

This post needs a link to the article right in the body of the post. Also, the link to Mark Fisher's original article does not seem to work (for me, anyway).

Regards,
Colin

Re: Link needed by Colin Sampaleanu

Sorry, I am talking about the news post meant to announce the article. I just realized the article itself also has these comments hanging off it.

Re: Link needed by Geoffrey Wiseman

Apologies. My fault, fixed.

Re: Using Spring @MVC for REST services by Gavin Terrill

Looks like SpringSource might be backing away from JAX-RS. Check out the comment from Juergen on Jan 7.

Re: Using Spring @MVC for REST services by Stefan Tilkov

The JAXRS stuff is a kind of a pain in the ass to use


Could you elaborate? What exactly do you consider to be a PITA?

Re: Using Spring @MVC for REST services by David Tkaczyk

Could you elaborate as to why find jax-rs to be a "pain in the ass" to use. I have had nothing but good luck with it and find it extremely easy to use. Maybe I haven't used as advanced features, but I'm curious as to why you think so. Thanks.

Re: Using Spring @MVC for REST services by Geoffrey Wiseman

I have had nothing but good luck with it and find it extremely easy to use. Maybe I haven't used as advanced features, but I'm curious as to why you think so. Thanks.


Out of curiosity, what JAX-RS implementation are you using? I've used Restlet in its pre-JAX-RS form and a few other approaches for rest, but still haven't done more than experiment with JAX-RS implementations, so I'm happy to hear feedback "from the field" as it were.

Re: Using Spring @MVC for REST services by Juergen Hoeller

Our core strategy is to bring REST to the Spring @MVC world in as natural a fashion as possible. This involves URI template support for Spring's @RequestMapping facility, a dedicated parameter-level @PathParam annotation for parameter extraction based on such a template, etc. This is supposed to be a natural next step after Spring MVC 2.5, preserving all common Spring MVC idioms; you could see it as "completing @MVC".



We'll also provide a RestTemplate class for client-side HTTP access to REST-style services.


Currently, the first Spring Framework 3.0 milestone - including a first cut of the dedicated REST support - is scheduled for mid September. We are aiming for GA fairly soon, with 3.0 RC1 being scheduled for December already.



With respect to JAX-RS: The JSR 311 spec essentially defines a dedicated REST resource endpoint model there, not being a great fit for REST-enabling an existing MVC endpoint model. This is why JAX-RS is not the primary point of our REST strategy.



We're considering integration with JAX-RS on a separate basis - separate from Spring MVC's own endpoint model -, possibly supporting the use of Jersey (the JAX-RS RI) with Spring-style beans in a Spring web application context. This might make Spring 3.0 as well, depending on the finalization of JSR 311 and Jersey in time for Spring 3.0 RC1. Otherwise it would be a candidate for Spring 3.1.



Juergen

Re: Using Spring @MVC for REST services by Terence Ingram

It sounds like Spring 3.0 will have what I am after. Integration with Jersey would be nice. We have been using both Jersey and Spring currently in our REST services. It would be nice to have them officially supported together.

Can an interceptor work with an annotation based form controller? by Vernon W

I wish that I read this article before I started working on the Spring 2.5 including the web layer. When I am working on coding for Spring 2.5 web layer, I can't figure out how to configure an interceptor with a form controller as what it can be done with the XML configuration approach. I have made non-form controllers work with an interceptor, but not a form controller. I have seen some examples of one interceptor for all controller. I only need to an interceptor for selected form controllers.

Does anyone have an information in this regard?

Part 3 of the Series? by Yohan Liyanage

Hi,

Does anyone have a link to Part 3 of this series?

Thanks

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

15 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2013 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT