diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfiguration.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfiguration.java index 0d84360134..c33fca40b3 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfiguration.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfiguration.java @@ -302,8 +302,7 @@ class WebMvcConfiguration implements ApplicationContextAware, ServletContextAwar private HandlerExceptionResolver createExceptionHandlerExceptionResolver() throws Exception { ExceptionHandlerExceptionResolver resolver = new ExceptionHandlerExceptionResolver(); - resolver.setOrder(0); - + List> converters = new ArrayList>(); configurers.configureMessageConverters(converters); if (converters.size() == 0) { diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java index ee9f111c56..16a6a005ec 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java @@ -164,7 +164,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce this.messageConverters = messageConverters; } - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { if (argumentResolvers == null) { argumentResolvers = new HandlerMethodArgumentResolverComposite(); argumentResolvers.addResolvers(customArgumentResolvers); diff --git a/spring-framework-reference/src/mvc.xml b/spring-framework-reference/src/mvc.xml index 54b094b9aa..6cc981bd40 100644 --- a/spring-framework-reference/src/mvc.xml +++ b/spring-framework-reference/src/mvc.xml @@ -2158,18 +2158,31 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { The RedirectView issues an HttpServletResponse.sendRedirect() call that - returns to the client browser as an HTTP redirect. All - model attributes are exposed as HTTP query parameters. This means that - the model must contain only objects (generally Strings or objects - converted to a String representation), which can be readily converted - to a textual HTTP query parameter. + returns to the client browser as an HTTP redirect. + All model attributes are considered to be exposed as either URI template variables first, + assuming the URL is a URI template such as /account/{number}, + or as HTTP query parameters second. By default String and primitive model attributes + are eligible to be exposed this way. However, this behavior can be extended by + sub-classing RedirectView. Also consider that @PathVariable-annotated + method arguments are automatically added to the model, which is convenient when + redirecting to the same URL using a different HTTP method. For example: + + @RequestMapping(value = "/files/{path}", method = RequestMethod.POST) +public String upload(@PathVariable String path, ...) { + // ... + return "redirect:files/{path}; +} + +@RequestMapping(value = "/files/{path}", method = RequestMethod.GET) +public void get(@PathVariable String path, ...) { + // ... +} If you use RedirectView and the view is created by the controller itself, it is recommended that you configure the redirect URL to be injected into the controller so that it is not baked into the controller but configured in the context along with the - view names. The - next section discusses this process. + view names. The next section discusses this process.
@@ -2194,13 +2207,10 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter { The net effect is the same as if the controller had returned a RedirectView, but now the controller itself can simply operate in terms of logical view names. A logical view name - such as redirect:/my/response/controller.html will + such as redirect:/myapp/some/resource will redirect relative to the current servlet context, while a name such as - redirect:http://myhost.com/some/arbitrary/path.html - will redirect to an absolute URL. The important thing is that, as long - as this redirect view name is injected into the controller like any - other logical view name, the controller is not even aware that - redirection is happening. + redirect:http://myhost.com/some/arbitrary/path + will redirect to an absolute URL.