diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 497e71190c..7473330449 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -51,7 +51,6 @@ import org.springframework.util.ClassUtils; import org.springframework.validation.Errors; import org.springframework.validation.MessageCodesResolver; import org.springframework.validation.Validator; -import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; import org.springframework.web.HttpRequestHandler; import org.springframework.web.accept.ContentNegotiationManager; import org.springframework.web.bind.WebDataBinder; @@ -88,49 +87,49 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv * *

This class registers the following {@link HandlerMapping}s:

* * *

Registers these {@link HandlerAdapter}s: *

* *

Registers a {@link HandlerExceptionResolverComposite} with this chain of * exception resolvers: *

* *

Both the {@link RequestMappingHandlerAdapter} and the * {@link ExceptionHandlerExceptionResolver} are configured with default * instances of the following by default: *

* * @author Rossen Stoyanchev @@ -343,9 +342,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv * through annotated controller methods. Consider overriding one of these * other more fine-grained methods: * */ @Bean @@ -612,23 +611,26 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv * A method available to subclasses for adding default {@link HandlerExceptionResolver}s. *

Adds the following exception resolvers: *

*/ protected final void addDefaultHandlerExceptionResolvers(List exceptionResolvers) { ExceptionHandlerExceptionResolver exceptionHandlerExceptionResolver = new ExceptionHandlerExceptionResolver(); - exceptionHandlerExceptionResolver.setApplicationContext(this.applicationContext); exceptionHandlerExceptionResolver.setContentNegotiationManager(mvcContentNegotiationManager()); exceptionHandlerExceptionResolver.setMessageConverters(getMessageConverters()); + exceptionHandlerExceptionResolver.setApplicationContext(this.applicationContext); exceptionHandlerExceptionResolver.afterPropertiesSet(); - exceptionResolvers.add(exceptionHandlerExceptionResolver); - exceptionResolvers.add(new ResponseStatusExceptionResolver()); + + ResponseStatusExceptionResolver responseStatusExceptionResolver = new ResponseStatusExceptionResolver(); + responseStatusExceptionResolver.setMessageSource(this.applicationContext); + exceptionResolvers.add(responseStatusExceptionResolver); + exceptionResolvers.add(new DefaultHandlerExceptionResolver()); }