|
|
|
@ -87,53 +87,54 @@ import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolv |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>This class registers the following {@link HandlerMapping}s:</p> |
|
|
|
* <p>This class registers the following {@link HandlerMapping}s:</p> |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link RequestMappingHandlerMapping} |
|
|
|
* <li>{@link RequestMappingHandlerMapping} |
|
|
|
* ordered at 0 for mapping requests to annotated controller methods. |
|
|
|
* ordered at 0 for mapping requests to annotated controller methods. |
|
|
|
* <li>{@link HandlerMapping} |
|
|
|
* <li>{@link HandlerMapping} |
|
|
|
* ordered at 1 to map URL paths directly to view names. |
|
|
|
* ordered at 1 to map URL paths directly to view names. |
|
|
|
* <li>{@link BeanNameUrlHandlerMapping} |
|
|
|
* <li>{@link BeanNameUrlHandlerMapping} |
|
|
|
* ordered at 2 to map URL paths to controller bean names. |
|
|
|
* ordered at 2 to map URL paths to controller bean names. |
|
|
|
* <li>{@link HandlerMapping} |
|
|
|
* <li>{@link HandlerMapping} |
|
|
|
* ordered at {@code Integer.MAX_VALUE-1} to serve static resource requests. |
|
|
|
* ordered at {@code Integer.MAX_VALUE-1} to serve static resource requests. |
|
|
|
* <li>{@link HandlerMapping} |
|
|
|
* <li>{@link HandlerMapping} |
|
|
|
* ordered at {@code Integer.MAX_VALUE} to forward requests to the default servlet. |
|
|
|
* ordered at {@code Integer.MAX_VALUE} to forward requests to the default servlet. |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Registers these {@link HandlerAdapter}s: |
|
|
|
* <p>Registers these {@link HandlerAdapter}s: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link RequestMappingHandlerAdapter} |
|
|
|
* <li>{@link RequestMappingHandlerAdapter} |
|
|
|
* for processing requests with annotated controller methods. |
|
|
|
* for processing requests with annotated controller methods. |
|
|
|
* <li>{@link HttpRequestHandlerAdapter} |
|
|
|
* <li>{@link HttpRequestHandlerAdapter} |
|
|
|
* for processing requests with {@link HttpRequestHandler}s. |
|
|
|
* for processing requests with {@link HttpRequestHandler}s. |
|
|
|
* <li>{@link SimpleControllerHandlerAdapter} |
|
|
|
* <li>{@link SimpleControllerHandlerAdapter} |
|
|
|
* for processing requests with interface-based {@link Controller}s. |
|
|
|
* for processing requests with interface-based {@link Controller}s. |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Registers a {@link HandlerExceptionResolverComposite} with this chain of |
|
|
|
* <p>Registers a {@link HandlerExceptionResolverComposite} with this chain of |
|
|
|
* exception resolvers: |
|
|
|
* exception resolvers: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions |
|
|
|
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions |
|
|
|
* through @{@link ExceptionHandler} methods. |
|
|
|
* through @{@link ExceptionHandler} methods. |
|
|
|
* <li>{@link ResponseStatusExceptionResolver} for exceptions annotated |
|
|
|
* <li>{@link ResponseStatusExceptionResolver} for exceptions annotated |
|
|
|
* with @{@link ResponseStatus}. |
|
|
|
* with @{@link ResponseStatus}. |
|
|
|
* <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring |
|
|
|
* <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring |
|
|
|
* exception types |
|
|
|
* exception types |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Both the {@link RequestMappingHandlerAdapter} and the |
|
|
|
* <p>Both the {@link RequestMappingHandlerAdapter} and the |
|
|
|
* {@link ExceptionHandlerExceptionResolver} are configured with default |
|
|
|
* {@link ExceptionHandlerExceptionResolver} are configured with default |
|
|
|
* instances of the following by default: |
|
|
|
* instances of the following by default: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>A {@link ContentNegotiationManager} |
|
|
|
* <li>a {@link ContentNegotiationManager} |
|
|
|
* <li>A {@link DefaultFormattingConversionService} |
|
|
|
* <li>a {@link DefaultFormattingConversionService} |
|
|
|
* <li>A {@link org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean} |
|
|
|
* <li>a {@link org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean} |
|
|
|
* if a JSR-303 implementation is available on the classpath |
|
|
|
* if a JSR-303 implementation is available on the classpath |
|
|
|
* <li>A range of {@link HttpMessageConverter}s depending on the 3rd party |
|
|
|
* <li>a range of {@link HttpMessageConverter}s depending on the third-party |
|
|
|
* libraries available on the classpath. |
|
|
|
* libraries available on the classpath. |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
* @author Brian Clozel |
|
|
|
* @author Brian Clozel |
|
|
|
|
|
|
|
* @author Sebastien Deleuze |
|
|
|
* @since 3.1 |
|
|
|
* @since 3.1 |
|
|
|
* @see EnableWebMvc |
|
|
|
* @see EnableWebMvc |
|
|
|
* @see WebMvcConfigurer |
|
|
|
* @see WebMvcConfigurer |
|
|
|
@ -373,9 +374,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
* through annotated controller methods. Consider overriding one of these |
|
|
|
* through annotated controller methods. Consider overriding one of these |
|
|
|
* other more fine-grained methods: |
|
|
|
* other more fine-grained methods: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link #addArgumentResolvers} for adding custom argument resolvers. |
|
|
|
* <li>{@link #addArgumentResolvers} for adding custom argument resolvers. |
|
|
|
* <li>{@link #addReturnValueHandlers} for adding custom return value handlers. |
|
|
|
* <li>{@link #addReturnValueHandlers} for adding custom return value handlers. |
|
|
|
* <li>{@link #configureMessageConverters} for adding custom message converters. |
|
|
|
* <li>{@link #configureMessageConverters} for adding custom message converters. |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
@ -653,23 +654,26 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
* A method available to subclasses for adding default {@link HandlerExceptionResolver}s. |
|
|
|
* A method available to subclasses for adding default {@link HandlerExceptionResolver}s. |
|
|
|
* <p>Adds the following exception resolvers: |
|
|
|
* <p>Adds the following exception resolvers: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link ExceptionHandlerExceptionResolver} |
|
|
|
* <li>{@link ExceptionHandlerExceptionResolver} |
|
|
|
* for handling exceptions through @{@link ExceptionHandler} methods. |
|
|
|
* for handling exceptions through @{@link ExceptionHandler} methods. |
|
|
|
* <li>{@link ResponseStatusExceptionResolver} |
|
|
|
* <li>{@link ResponseStatusExceptionResolver} |
|
|
|
* for exceptions annotated with @{@link ResponseStatus}. |
|
|
|
* for exceptions annotated with @{@link ResponseStatus}. |
|
|
|
* <li>{@link DefaultHandlerExceptionResolver} |
|
|
|
* <li>{@link DefaultHandlerExceptionResolver} |
|
|
|
* for resolving known Spring exception types |
|
|
|
* for resolving known Spring exception types |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected final void addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { |
|
|
|
protected final void addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { |
|
|
|
ExceptionHandlerExceptionResolver exceptionHandlerExceptionResolver = new ExceptionHandlerExceptionResolver(); |
|
|
|
ExceptionHandlerExceptionResolver exceptionHandlerExceptionResolver = new ExceptionHandlerExceptionResolver(); |
|
|
|
exceptionHandlerExceptionResolver.setApplicationContext(this.applicationContext); |
|
|
|
|
|
|
|
exceptionHandlerExceptionResolver.setContentNegotiationManager(mvcContentNegotiationManager()); |
|
|
|
exceptionHandlerExceptionResolver.setContentNegotiationManager(mvcContentNegotiationManager()); |
|
|
|
exceptionHandlerExceptionResolver.setMessageConverters(getMessageConverters()); |
|
|
|
exceptionHandlerExceptionResolver.setMessageConverters(getMessageConverters()); |
|
|
|
|
|
|
|
exceptionHandlerExceptionResolver.setApplicationContext(this.applicationContext); |
|
|
|
exceptionHandlerExceptionResolver.afterPropertiesSet(); |
|
|
|
exceptionHandlerExceptionResolver.afterPropertiesSet(); |
|
|
|
|
|
|
|
|
|
|
|
exceptionResolvers.add(exceptionHandlerExceptionResolver); |
|
|
|
exceptionResolvers.add(exceptionHandlerExceptionResolver); |
|
|
|
exceptionResolvers.add(new ResponseStatusExceptionResolver()); |
|
|
|
|
|
|
|
|
|
|
|
ResponseStatusExceptionResolver responseStatusExceptionResolver = new ResponseStatusExceptionResolver(); |
|
|
|
|
|
|
|
responseStatusExceptionResolver.setMessageSource(this.applicationContext); |
|
|
|
|
|
|
|
exceptionResolvers.add(responseStatusExceptionResolver); |
|
|
|
|
|
|
|
|
|
|
|
exceptionResolvers.add(new DefaultHandlerExceptionResolver()); |
|
|
|
exceptionResolvers.add(new DefaultHandlerExceptionResolver()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|