|
|
|
@ -73,42 +73,59 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl |
|
|
|
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver; |
|
|
|
import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* A base class that provides default configuration for Spring MVC applications by registering Spring MVC |
|
|
|
* A base class that provides default configuration for Spring MVC applications |
|
|
|
* infrastructure components to be detected by the {@link DispatcherServlet}. Typically applications should not |
|
|
|
* by registering Spring MVC infrastructure components to be detected by the |
|
|
|
* have to extend this class. A more likely place to start is to annotate an @{@link Configuration} |
|
|
|
* {@link DispatcherServlet}. An application configuration class is not required |
|
|
|
* class with @{@link EnableWebMvc} (see @{@link EnableWebMvc} and {@link WebMvcConfigurer} for details). |
|
|
|
* to extend this class. A more likely place to start is to annotate |
|
|
|
|
|
|
|
* an @{@link Configuration} class with @{@link EnableWebMvc} |
|
|
|
|
|
|
|
* (see @{@link EnableWebMvc} and {@link WebMvcConfigurer} for details). |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>If using @{@link EnableWebMvc} does not give you all you need, consider extending directly from this |
|
|
|
* <p>If the customization options available with use of @{@link EnableWebMvc} |
|
|
|
* class. Remember to add @{@link Configuration} to your subclass and @{@link Bean} to any superclass |
|
|
|
* are not enough, consider extending directly from this class and override the |
|
|
|
* @{@link Bean} methods you choose to override. |
|
|
|
* appropriate methods. Remember to add @{@link Configuration} to your subclass |
|
|
|
|
|
|
|
* and @{@link Bean} to any superclass @{@link Bean} methods you override. |
|
|
|
* |
|
|
|
* |
|
|
|
* <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} ordered at 0 for mapping requests to annotated controller methods. |
|
|
|
* <li>{@link RequestMappingHandlerMapping} |
|
|
|
* <li>{@link HandlerMapping} ordered at 1 to map URL paths directly to view names. |
|
|
|
* ordered at 0 for mapping requests to annotated controller methods. |
|
|
|
* <li>{@link BeanNameUrlHandlerMapping} 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 1 to map URL paths directly to view names. |
|
|
|
* <li>{@link HandlerMapping} ordered at {@code Integer.MAX_VALUE} to forward requests to the default servlet. |
|
|
|
* <li>{@link BeanNameUrlHandlerMapping} |
|
|
|
|
|
|
|
* ordered at 2 to map URL paths to controller bean names. |
|
|
|
|
|
|
|
* <li>{@link HandlerMapping} |
|
|
|
|
|
|
|
* ordered at {@code Integer.MAX_VALUE-1} to serve static resource requests. |
|
|
|
|
|
|
|
* <li>{@link HandlerMapping} |
|
|
|
|
|
|
|
* 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} for processing requests with annotated controller methods. |
|
|
|
* <li>{@link RequestMappingHandlerAdapter} |
|
|
|
* <li>{@link HttpRequestHandlerAdapter} for processing requests with {@link HttpRequestHandler}s. |
|
|
|
* for processing requests with annotated controller methods. |
|
|
|
* <li>{@link SimpleControllerHandlerAdapter} for processing requests with interface-based {@link Controller}s. |
|
|
|
* <li>{@link HttpRequestHandlerAdapter} |
|
|
|
|
|
|
|
* for processing requests with {@link HttpRequestHandler}s. |
|
|
|
|
|
|
|
* <li>{@link SimpleControllerHandlerAdapter} |
|
|
|
|
|
|
|
* for processing requests with interface-based {@link Controller}s. |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Registers a {@link HandlerExceptionResolverComposite} with this chain of exception resolvers: |
|
|
|
* <p>Registers a {@link HandlerExceptionResolverComposite} with this chain of |
|
|
|
|
|
|
|
* exception resolvers: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions through @{@link ExceptionHandler} methods. |
|
|
|
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions |
|
|
|
* <li>{@link ResponseStatusExceptionResolver} for exceptions annotated with @{@link ResponseStatus}. |
|
|
|
* through @{@link ExceptionHandler} methods. |
|
|
|
* <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring exception types |
|
|
|
* <li>{@link ResponseStatusExceptionResolver} for exceptions annotated |
|
|
|
|
|
|
|
* with @{@link ResponseStatus}. |
|
|
|
|
|
|
|
* <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring |
|
|
|
|
|
|
|
* exception types |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Registers these other instances: |
|
|
|
* <p>Registers these other instances: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link FormattingConversionService} for use with annotated controller methods and the spring:eval JSP tag. |
|
|
|
* <li>{@link FormattingConversionService} |
|
|
|
* <li>{@link Validator} for validating model attributes on annotated controller methods. |
|
|
|
* for use with annotated controller methods and the spring:eval JSP tag. |
|
|
|
|
|
|
|
* <li>{@link Validator} |
|
|
|
|
|
|
|
* for validating model attributes on annotated controller methods. |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* @see EnableWebMvc |
|
|
|
* @see EnableWebMvc |
|
|
|
@ -137,7 +154,8 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a {@link RequestMappingHandlerMapping} ordered at 0 for mapping requests to annotated controllers. |
|
|
|
* Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping |
|
|
|
|
|
|
|
* requests to annotated controllers. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public RequestMappingHandlerMapping requestMappingHandlerMapping() { |
|
|
|
public RequestMappingHandlerMapping requestMappingHandlerMapping() { |
|
|
|
@ -148,8 +166,9 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Provides access to the shared handler interceptors used to configure {@link HandlerMapping} instances with. |
|
|
|
* Provide access to the shared handler interceptors used to configure |
|
|
|
* This method cannot be overridden, use {@link #addInterceptors(InterceptorRegistry)} instead. |
|
|
|
* {@link HandlerMapping} instances with. This method cannot be overridden, |
|
|
|
|
|
|
|
* use {@link #addInterceptors(InterceptorRegistry)} instead. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected final Object[] getInterceptors() { |
|
|
|
protected final Object[] getInterceptors() { |
|
|
|
if (interceptors == null) { |
|
|
|
if (interceptors == null) { |
|
|
|
@ -162,15 +181,17 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Override this method to add Spring MVC interceptors for pre/post-processing of controller invocation. |
|
|
|
* Override this method to add Spring MVC interceptors for |
|
|
|
|
|
|
|
* pre- and post-processing of controller invocation. |
|
|
|
* @see InterceptorRegistry |
|
|
|
* @see InterceptorRegistry |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void addInterceptors(InterceptorRegistry registry) { |
|
|
|
protected void addInterceptors(InterceptorRegistry registry) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a handler mapping ordered at 1 to map URL paths directly to view names. |
|
|
|
* Return a handler mapping ordered at 1 to map URL paths directly to |
|
|
|
* To configure view controllers, override {@link #addViewControllers(ViewControllerRegistry)}. |
|
|
|
* view names. To configure view controllers, override |
|
|
|
|
|
|
|
* {@link #addViewControllers}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public HandlerMapping viewControllerHandlerMapping() { |
|
|
|
public HandlerMapping viewControllerHandlerMapping() { |
|
|
|
@ -191,7 +212,8 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a {@link BeanNameUrlHandlerMapping} ordered at 2 to map URL paths to controller bean names. |
|
|
|
* Return a {@link BeanNameUrlHandlerMapping} ordered at 2 to map URL |
|
|
|
|
|
|
|
* paths to controller bean names. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public BeanNameUrlHandlerMapping beanNameHandlerMapping() { |
|
|
|
public BeanNameUrlHandlerMapping beanNameHandlerMapping() { |
|
|
|
@ -202,8 +224,9 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a handler mapping ordered at Integer.MAX_VALUE-1 with mapped resource handlers. |
|
|
|
* Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped |
|
|
|
* To configure resource handling, override {@link #addResourceHandlers(ResourceHandlerRegistry)}. |
|
|
|
* resource handlers. To configure resource handling, override |
|
|
|
|
|
|
|
* {@link #addResourceHandlers}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public HandlerMapping resourceHandlerMapping() { |
|
|
|
public HandlerMapping resourceHandlerMapping() { |
|
|
|
@ -222,9 +245,9 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a handler mapping ordered at Integer.MAX_VALUE with a mapped default servlet handler. |
|
|
|
* Return a handler mapping ordered at Integer.MAX_VALUE with a mapped |
|
|
|
* To configure "default" Servlet handling, override |
|
|
|
* default servlet handler. To configure "default" Servlet handling, |
|
|
|
* {@link #configureDefaultServletHandling(DefaultServletHandlerConfigurer)}. |
|
|
|
* override {@link #configureDefaultServletHandling}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public HandlerMapping defaultServletHandlerMapping() { |
|
|
|
public HandlerMapping defaultServletHandlerMapping() { |
|
|
|
@ -243,12 +266,13 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a {@link RequestMappingHandlerAdapter} for processing requests through annotated controller methods. |
|
|
|
* Returns a {@link RequestMappingHandlerAdapter} for processing requests |
|
|
|
* Consider overriding one of these other more fine-grained methods: |
|
|
|
* through annotated controller methods. Consider overriding one of these |
|
|
|
|
|
|
|
* other more fine-grained methods: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link #addArgumentResolvers(List)} for adding custom argument resolvers. |
|
|
|
* <li>{@link #addArgumentResolvers} for adding custom argument resolvers. |
|
|
|
* <li>{@link #addReturnValueHandlers(List)} for adding custom return value handlers. |
|
|
|
* <li>{@link #addReturnValueHandlers} for adding custom return value handlers. |
|
|
|
* <li>{@link #configureMessageConverters(List)} for adding custom message converters. |
|
|
|
* <li>{@link #configureMessageConverters} for adding custom message converters. |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
@ -268,34 +292,46 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
adapter.setWebBindingInitializer(webBindingInitializer); |
|
|
|
adapter.setWebBindingInitializer(webBindingInitializer); |
|
|
|
adapter.setCustomArgumentResolvers(argumentResolvers); |
|
|
|
adapter.setCustomArgumentResolvers(argumentResolvers); |
|
|
|
adapter.setCustomReturnValueHandlers(returnValueHandlers); |
|
|
|
adapter.setCustomReturnValueHandlers(returnValueHandlers); |
|
|
|
|
|
|
|
adapter.setIgnoreDefaultModelOnRedirect(true); |
|
|
|
return adapter; |
|
|
|
return adapter; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Add custom {@link HandlerMethodArgumentResolver}s to use in addition to the ones registered by default. |
|
|
|
* Add custom {@link HandlerMethodArgumentResolver}s to use in addition to |
|
|
|
* <p>Custom argument resolvers are invoked before built-in resolvers except for those that rely on the presence |
|
|
|
* the ones registered by default. |
|
|
|
* of annotations (e.g. {@code @RequestParameter}, {@code @PathVariable}, etc.). The latter can be customized |
|
|
|
* <p>Custom argument resolvers are invoked before built-in resolvers |
|
|
|
* by configuring the {@link RequestMappingHandlerAdapter} directly. |
|
|
|
* except for those that rely on the presence of annotations (e.g. |
|
|
|
* @param argumentResolvers the list of custom converters; initially an empty list. |
|
|
|
* {@code @RequestParameter}, {@code @PathVariable}, etc.). |
|
|
|
|
|
|
|
* The latter can be customized by configuring the |
|
|
|
|
|
|
|
* {@link RequestMappingHandlerAdapter} directly. |
|
|
|
|
|
|
|
* @param argumentResolvers the list of custom converters; |
|
|
|
|
|
|
|
* initially an empty list. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { |
|
|
|
protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Add custom {@link HandlerMethodReturnValueHandler}s in addition to the ones registered by default. |
|
|
|
* Add custom {@link HandlerMethodReturnValueHandler}s in addition to the |
|
|
|
* <p>Custom return value handlers are invoked before built-in ones except for those that rely on the presence |
|
|
|
* ones registered by default. |
|
|
|
* of annotations (e.g. {@code @ResponseBody}, {@code @ModelAttribute}, etc.). The latter can be customized |
|
|
|
* <p>Custom return value handlers are invoked before built-in ones except |
|
|
|
* by configuring the {@link RequestMappingHandlerAdapter} directly. |
|
|
|
* for those that rely on the presence of annotations (e.g. |
|
|
|
* @param returnValueHandlers the list of custom handlers; initially an empty list. |
|
|
|
* {@code @ResponseBody}, {@code @ModelAttribute}, etc.). |
|
|
|
|
|
|
|
* The latter can be customized by configuring the |
|
|
|
|
|
|
|
* {@link RequestMappingHandlerAdapter} directly. |
|
|
|
|
|
|
|
* @param returnValueHandlers the list of custom handlers; |
|
|
|
|
|
|
|
* initially an empty list. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { |
|
|
|
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Provides access to the shared {@link HttpMessageConverter}s used by the |
|
|
|
* Provides access to the shared {@link HttpMessageConverter}s used by the |
|
|
|
* {@link RequestMappingHandlerAdapter} and the {@link ExceptionHandlerExceptionResolver}. |
|
|
|
* {@link RequestMappingHandlerAdapter} and the |
|
|
|
* This method cannot be overridden. Use {@link #configureMessageConverters(List)} instead. |
|
|
|
* {@link ExceptionHandlerExceptionResolver}. |
|
|
|
* Also see {@link #addDefaultHttpMessageConverters(List)} that can be used to add default message converters. |
|
|
|
* This method cannot be overridden. |
|
|
|
|
|
|
|
* Use {@link #configureMessageConverters(List)} instead. |
|
|
|
|
|
|
|
* Also see {@link #addDefaultHttpMessageConverters(List)} that can be |
|
|
|
|
|
|
|
* used to add default message converters. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected final List<HttpMessageConverter<?>> getMessageConverters() { |
|
|
|
protected final List<HttpMessageConverter<?>> getMessageConverters() { |
|
|
|
if (messageConverters == null) { |
|
|
|
if (messageConverters == null) { |
|
|
|
@ -309,17 +345,20 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Override this method to add custom {@link HttpMessageConverter}s to use with |
|
|
|
* Override this method to add custom {@link HttpMessageConverter}s to use |
|
|
|
* the {@link RequestMappingHandlerAdapter} and the {@link ExceptionHandlerExceptionResolver}. |
|
|
|
* with the {@link RequestMappingHandlerAdapter} and the |
|
|
|
* Adding converters to the list turns off the default converters that would otherwise be registered by default. |
|
|
|
* {@link ExceptionHandlerExceptionResolver}. Adding converters to the |
|
|
|
* Also see {@link #addDefaultHttpMessageConverters(List)} that can be used to add default message converters. |
|
|
|
* list turns off the default converters that would otherwise be registered |
|
|
|
* @param converters a list to add message converters to; initially an empty list. |
|
|
|
* by default. Also see {@link #addDefaultHttpMessageConverters(List)} that |
|
|
|
|
|
|
|
* can be used to add default message converters. |
|
|
|
|
|
|
|
* @param converters a list to add message converters to; |
|
|
|
|
|
|
|
* initially an empty list. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) { |
|
|
|
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* A method available to subclasses to add default {@link HttpMessageConverter}s. |
|
|
|
* Override this method to add default {@link HttpMessageConverter}s. |
|
|
|
* @param messageConverters the list to add the default message converters to |
|
|
|
* @param messageConverters the list to add the default message converters to |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters) { |
|
|
|
protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters) { |
|
|
|
@ -346,9 +385,9 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a {@link FormattingConversionService} for use with annotated controller methods and the |
|
|
|
* Returns a {@link FormattingConversionService} for use with annotated |
|
|
|
* {@code spring:eval} JSP tag. Also see {@link #addFormatters(FormatterRegistry)} as an alternative |
|
|
|
* controller methods and the {@code spring:eval} JSP tag. |
|
|
|
* to overriding this method. |
|
|
|
* Also see {@link #addFormatters} as an alternative to overriding this method. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public FormattingConversionService mvcConversionService() { |
|
|
|
public FormattingConversionService mvcConversionService() { |
|
|
|
@ -364,8 +403,9 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns {@link Validator} for validating {@code @ModelAttribute} and {@code @RequestBody} arguments of |
|
|
|
* Returns {@link Validator} for validating {@code @ModelAttribute} |
|
|
|
* annotated controller methods. To configure a custom validation, override {@link #getValidator()}. |
|
|
|
* and {@code @RequestBody} arguments of annotated controller methods. |
|
|
|
|
|
|
|
* To configure a custom validation, override {@link #getValidator()}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
Validator mvcValidator() { |
|
|
|
Validator mvcValidator() { |
|
|
|
@ -404,7 +444,8 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a {@link HttpRequestHandlerAdapter} for processing requests with {@link HttpRequestHandler}s. |
|
|
|
* Returns a {@link HttpRequestHandlerAdapter} for processing requests |
|
|
|
|
|
|
|
* with {@link HttpRequestHandler}s. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public HttpRequestHandlerAdapter httpRequestHandlerAdapter() { |
|
|
|
public HttpRequestHandlerAdapter httpRequestHandlerAdapter() { |
|
|
|
@ -412,7 +453,8 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a {@link SimpleControllerHandlerAdapter} for processing requests with interface-based controllers. |
|
|
|
* Returns a {@link SimpleControllerHandlerAdapter} for processing requests |
|
|
|
|
|
|
|
* with interface-based controllers. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public SimpleControllerHandlerAdapter simpleControllerHandlerAdapter() { |
|
|
|
public SimpleControllerHandlerAdapter simpleControllerHandlerAdapter() { |
|
|
|
@ -420,8 +462,9 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a {@link HandlerExceptionResolverComposite} that contains a list of exception resolvers. |
|
|
|
* Returns a {@link HandlerExceptionResolverComposite} that contains a list |
|
|
|
* To customize the list of exception resolvers, override {@link #configureHandlerExceptionResolvers(List)}. |
|
|
|
* of exception resolvers. To customize the list of exception resolvers, |
|
|
|
|
|
|
|
* override {@link #configureHandlerExceptionResolvers(List)}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
HandlerExceptionResolver handlerExceptionResolver() throws Exception { |
|
|
|
HandlerExceptionResolver handlerExceptionResolver() throws Exception { |
|
|
|
@ -439,21 +482,28 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Override this method to configure the list of {@link HandlerExceptionResolver}s to use. |
|
|
|
* Override this method to configure the list of |
|
|
|
* Adding resolvers to the list turns off the default resolvers that would otherwise be registered by default. |
|
|
|
* {@link HandlerExceptionResolver}s to use. Adding resolvers to the list |
|
|
|
* Also see {@link #addDefaultHandlerExceptionResolvers(List)} that can be used to add the default exception resolvers. |
|
|
|
* turns off the default resolvers that would otherwise be registered by |
|
|
|
* @param exceptionResolvers a list to add exception resolvers to; initially an empty list. |
|
|
|
* default. Also see {@link #addDefaultHandlerExceptionResolvers(List)} |
|
|
|
|
|
|
|
* that can be used to add the default exception resolvers. |
|
|
|
|
|
|
|
* @param exceptionResolvers a list to add exception resolvers to; |
|
|
|
|
|
|
|
* initially an empty list. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { |
|
|
|
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 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} for handling exceptions through @{@link ExceptionHandler} methods. |
|
|
|
* <li>{@link ExceptionHandlerExceptionResolver} |
|
|
|
* <li>{@link ResponseStatusExceptionResolver} for exceptions annotated with @{@link ResponseStatus}. |
|
|
|
* for handling exceptions through @{@link ExceptionHandler} methods. |
|
|
|
* <li>{@link DefaultHandlerExceptionResolver} for resolving known Spring exception types |
|
|
|
* <li>{@link ResponseStatusExceptionResolver} |
|
|
|
|
|
|
|
* for exceptions annotated with @{@link ResponseStatus}. |
|
|
|
|
|
|
|
* <li>{@link DefaultHandlerExceptionResolver} |
|
|
|
|
|
|
|
* for resolving known Spring exception types |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected final void addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { |
|
|
|
protected final void addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) { |
|
|
|
|