org.springframework.web.servlet.config.annotation
Class WebMvcConfigurerAdapter

java.lang.Object
  extended by org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
All Implemented Interfaces:
WebMvcConfigurer

public abstract class WebMvcConfigurerAdapter
extends Object
implements WebMvcConfigurer

An abstract class with empty method implementations of WebMvcConfigurer. Subclasses can override only the methods they need.

Since:
3.1
Author:
Rossen Stoyanchev

Constructor Summary
WebMvcConfigurerAdapter()
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebMvcConfigurerAdapter

public WebMvcConfigurerAdapter()
Method Detail

addFormatters

public void addFormatters(FormatterRegistry registry)
Add Converters and Formatters in addition to the ones registered by default.

This implementation is empty.

Specified by:
addFormatters in interface WebMvcConfigurer

configureMessageConverters

public 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. Specifying custom converters overrides the converters registered by default.

This implementation is empty.

Specified by:
configureMessageConverters in interface WebMvcConfigurer
Parameters:
converters - a list to add message converters to

getValidator

public Validator getValidator()
Provide a custom 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.

This implementation returns null

Specified by:
getValidator in interface WebMvcConfigurer

addArgumentResolvers

public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)
Add custom 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.

This implementation is empty.

Specified by:
addArgumentResolvers in interface WebMvcConfigurer
Parameters:
argumentResolvers - the list of custom converters, initially empty

addReturnValueHandlers

public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)
Add custom 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.

This implementation is empty.

Specified by:
addReturnValueHandlers in interface WebMvcConfigurer
Parameters:
returnValueHandlers - the list of custom handlers, initially empty

configureHandlerExceptionResolvers

public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers)
Configure the list of HandlerExceptionResolvers to use for handling unresolved controller exceptions. Specifying exception resolvers overrides the ones registered by default.

This implementation is empty.

Specified by:
configureHandlerExceptionResolvers in interface WebMvcConfigurer
Parameters:
exceptionResolvers - a list to add exception resolvers to

configureInterceptors

public void configureInterceptors(InterceptorConfigurer configurer)
Configure the Spring MVC interceptors to use. Interceptors can be of type 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.

This implementation is empty.

Specified by:
configureInterceptors in interface WebMvcConfigurer
See Also:
InterceptorConfigurer

configureViewControllers

public void configureViewControllers(ViewControllerConfigurer configurer)
Configure the view controllers to use. A view controller is used to map a URL path directly to a view name. This is convenient when a request does not require controller logic.

This implementation is empty.

Specified by:
configureViewControllers in interface WebMvcConfigurer

configureResourceHandling

public 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. Resources can be served out of locations under web application root, from the classpath, and others.

This implementation is empty.

Specified by:
configureResourceHandling in interface WebMvcConfigurer

configureDefaultServletHandling

public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer)
Configure a handler for delegating unhandled requests by forwarding to the Servlet container's default servlet. This is commonly used when the 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.

This implementation is empty.

Specified by:
configureDefaultServletHandling in interface WebMvcConfigurer