BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Article: Spring 2.5: New Features in Spring MVC

Article: Spring 2.5: New Features in Spring MVC

Bookmarks
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.

Rate this Article

Adoption
Style

Hello stranger!

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

Get the most out of the InfoQ experience.

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

Community comments

  • Using Spring @MVC for REST services

    by Terence Ingram,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

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

  • Re: Using Spring @MVC for REST services

    by Geoffrey Wiseman,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Apologies. My fault, fixed.

  • Re: Using Spring @MVC for REST services

    by Gavin Terrill,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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

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

BT