From b06b5502e0934e49b2e7a77786a5eb50cc6f2996 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Sun, 5 Jun 2011 21:45:31 +0000 Subject: [PATCH] Updates to whats new in Spring 3.1 section --- spring-framework-reference/src/mvc.xml | 2 +- spring-framework-reference/src/new-in-3.1.xml | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index 058be3827e2..33df21a5532 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -2230,7 +2230,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { @RequestMapping(value = "/files/{path}", method = RequestMethod.POST) public String upload(@PathVariable String path, ...) { // ... - return "redirect:files/{path}; + return "redirect:files/{path}"; } @RequestMapping(value = "/files/{path}", method = RequestMethod.GET) diff --git a/spring-framework-reference/src/new-in-3.1.xml b/spring-framework-reference/src/new-in-3.1.xml index ad4e66152fe..4e836dc2152 100644 --- a/spring-framework-reference/src/new-in-3.1.xml +++ b/spring-framework-reference/src/new-in-3.1.xml @@ -181,5 +181,75 @@ +
+ New HandlerMethod-based Support Classes For Annotated Controller Processing + Spring 3.1 introduces a new set of support classes for processing requests + with annotated controllers: + + RequestMappingHandlerMapping + RequestMappingHandlerAdapter + ExceptionHandlerExceptionResolver + + These classes are a replacement for the existing: + + DefaultAnnotationHandlerMapping + AnnotationMethodHandlerAdapter + AnnotationMethodHandlerExceptionResolver + + The new classes were developed in response to many requests to make + annotation controller support classes more customizable and open for extension. + Whereas previously you could configure a custom annotated controller method + argument resolver, with the new support classes you can customize the + processing for any supported method argument or return value type. + + See org.springframework.web.method.support.HandlerMethodArgumentResolver Javadoc + See org.springframework.web.method.support.HandlerMethodReturnValueHandler Javadoc + + A second notable difference is the introduction of a + HandlerMethod abstraction to represent an + @RequestMapping method. This abstraction is used + throughout by the new support classes as the handler instance. + For example a HandlerInterceptor can cast + the handler from Object to + HandlerMethod and get access to the target + controller method, its annotations, etc. + The new classes are enabled by default by the MVC namespace and by + Java-based configuration via @EnableWebMvc. The + existing classes will continue to be available but use of the new classes is + recommended going forward. +
+
+ Consumes and Produces <interface>@RequestMapping</interface> Conditions + Improved support for specifying media types consumed by a method through the + 'Content-Type' header as well as for producible types specified + through the 'Accept' header. + See and + + +
+
+ Working With URI Template Variables In Controller Methods + @PathVariable method arguments are now automatically added to the model. + If you declare any @PathVariable arguments on a + controller method you no longer need to add them to the model. + Redirect view strings can now be URI templates. + For example a controller can return "redirect:/blog/{year}/{month}". + The URI template will be expanded with variables from the model, which + of course includes @PathVariable method arguments + that are now automatically added to the model. + URI template variables are now included in data binding + in addition to request parameters, which are typically used for + populating a model. +
+
+ Validation For <interface>@RequestBody</interface> Method Arguments + An @RequestBody method argument annotated + with @Valid is now automatically validated with the + same Validator instance used to validate + an @ModelAttribute method argument. + Both the MVC namespace and @EnableWebMvc + automatically configure a JSR-303 Validator adapter + provided a JSR-303 implementation is available on the classpath. +