|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface WebMvcConfigurer
Defines options for customizing or adding to the default Spring MVC configuration enabled through the use
of @EnableWebMvc. The @Configuration class annotated with @EnableWebMvc
is the most obvious place to implement this interface. However all @Configuration classes and more generally
all Spring beans that implement this interface will be detected at startup and given a chance to customize Spring
MVC configuration provided it is enabled through @EnableWebMvc.
Implementations of this interface will find it convenient to extend WebMvcConfigurerAdapter that
provides default method implementations and allows overriding only methods of interest.
| Method Summary | |
|---|---|
void |
addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)
Add custom HandlerMethodArgumentResolvers to use in addition to the ones registered by default. |
void |
addFormatters(FormatterRegistry registry)
Add Converters and Formatters in addition to the ones registered by default. |
void |
addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)
Add custom HandlerMethodReturnValueHandlers to in addition to the ones registered by default. |
void |
configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer)
Configure a handler for delegating unhandled requests by forwarding to the Servlet container's default servlet. |
void |
configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers)
Configure the list of HandlerExceptionResolvers to use for handling unresolved controller exceptions. |
void |
configureInterceptors(InterceptorConfigurer configurer)
Configure the Spring MVC interceptors to use. |
void |
configureMessageConverters(List<HttpMessageConverter<?>> converters)
Configure the list of HttpMessageConverters to use when resolving method arguments or handling
return values in @RequestMapping and @ExceptionHandler methods. |
void |
configureResourceHandling(ResourceConfigurer configurer)
Configure a handler for serving static resources such as images, js, and, css files through Spring MVC including setting cache headers optimized for efficient loading in a web browser. |
void |
configureViewControllers(ViewControllerConfigurer configurer)
Configure the view controllers to use. |
Validator |
getValidator()
Provide a custom Validator type replacing the one that would be created by default otherwise. |
| Method Detail |
|---|
void addFormatters(FormatterRegistry registry)
Converters and Formatters in addition to the ones registered by default.
void configureMessageConverters(List<HttpMessageConverter<?>> converters)
HttpMessageConverters to use when resolving method arguments or handling
return values in @RequestMapping and @ExceptionHandler methods.
Specifying custom converters overrides the converters registered by default.
converters - a list to add message converters toValidator getValidator()
Validator type replacing the one that would be created by default otherwise. If this
method returns null, and assuming a JSR-303 implementation is available on the classpath, a validator
of type LocalValidatorFactoryBean is created by default.
void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)
HandlerMethodArgumentResolvers to use in addition to the ones registered by default.
Generally custom argument resolvers are invoked first. However this excludes default argument resolvers that
rely on the presence of annotations (e.g. @RequestParameter, @PathVariable, etc.). Those
argument resolvers are not customizable without configuring RequestMappingHandlerAdapter directly.
argumentResolvers - the list of custom converters, initially emptyvoid addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)
HandlerMethodReturnValueHandlers to in addition to the ones registered by default.
Generally custom return value handlers are invoked first. However this excludes default return value handlers
that rely on the presence of annotations (e.g. @ResponseBody, @ModelAttribute, etc.). Those
handlers are not customizable without configuring RequestMappingHandlerAdapter directly.
returnValueHandlers - the list of custom handlers, initially emptyvoid configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers)
HandlerExceptionResolvers to use for handling unresolved controller exceptions.
Specifying exception resolvers overrides the ones registered by default.
exceptionResolvers - a list to add exception resolvers tovoid configureInterceptors(InterceptorConfigurer configurer)
HandlerInterceptor or
WebRequestInterceptor. They allow requests to be pre/post processed before/after controller
invocation. Interceptors can be registered to apply to all requests or limited to a set of path patterns.
InterceptorConfigurervoid configureViewControllers(ViewControllerConfigurer configurer)
void configureResourceHandling(ResourceConfigurer configurer)
void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer)
DispatcherServlet is mapped to "/", which results in
cleaner URLs (without a servlet prefix) but may need to still allow some requests (e.g. static resources)
to be handled by the Servlet container's default servlet.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||