org.springframework.web.servlet.config.annotation

## Class WebMvcConfigurerAdapter

- java.lang.Object
- - org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter

- All Implemented Interfaces:
    WebMvcConfigurer

      public abstract class WebMvcConfigurerAdapter
      extends Object
      implements WebMvcConfigurer

  An implementation of `WebMvcConfigurer` with empty methods allowing sub-classes to override only the methods they're interested in.
  Since:
    3.1
  Author:
    Rossen Stoyanchev

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebMvcConfigurerAdapter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)` Add resolvers to support custom controller method argument types.
    `void` | `addFormatters(FormatterRegistry registry)` Add `Converter`s and `Formatter`s in addition to the ones registered by default.
    `void` | `addInterceptors(InterceptorRegistry registry)` Add Spring MVC lifecycle interceptors for pre- and post-processing of controller method invocations.
    `void` | `addResourceHandlers(ResourceHandlerRegistry registry)` Add handlers to serve static resources such as images, js, and, css files from specific locations under web application root, the classpath, and others.
    `void` | `addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)` Add handlers to support custom controller method return value types.
    `void` | `addViewControllers(ViewControllerRegistry registry)` Add view controllers to create a direct mapping between a URL path and view name without the need for a controller in between.
    `void` | `configureAsyncSupport(AsyncSupportConfigurer configurer)` Configure asynchronous request handling options.
    `void` | `configureContentNegotiation(ContentNegotiationConfigurer configurer)` Configure content negotiation options.
    `void` | `configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer)` Configure a handler to delegate unhandled requests by forwarding to the Servlet container's "default" servlet.
    `void` | `configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers)` Configure the `HandlerExceptionResolver`s to handle unresolved controller exceptions.
    `void` | `configureMessageConverters(List<HttpMessageConverter<?>> converters)` Configure the `HttpMessageConverter`s to use in argument resolvers and return value handlers that support reading and/or writing to the body of the request and response.
    `MessageCodesResolver` | `getMessageCodesResolver()` Provide a custom `MessageCodesResolver` for building message codes from data binding and validation error codes.
    `Validator` | `getValidator()` Provide a custom `Validator` instead of the one created by default.

    - ### 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 `Converter`s and `Formatter`s 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 `HttpMessageConverter`s to use in argument resolvers and return value handlers that support reading and/or writing to the body of the request and response. If no message converters are added to the list, default converters are added instead.

      This implementation is empty.

      Specified by:
        `configureMessageConverters` in interface `WebMvcConfigurer`
      Parameters:
        `converters` - initially an empty list of converters

    - #### getValidator

          public Validator getValidator()

      Provide a custom `Validator` instead of the one created by default. The default implementation, assuming JSR-303 is on the classpath, is: `LocalValidatorFactoryBean`. Leave the return value as `null` to keep the default.

      This implementation returns `null`

      Specified by:
        `getValidator` in interface `WebMvcConfigurer`

    - #### configureContentNegotiation

          public void configureContentNegotiation(ContentNegotiationConfigurer configurer)

      Configure content negotiation options.

      This implementation is empty.

      Specified by:
        `configureContentNegotiation` in interface `WebMvcConfigurer`

    - #### configureAsyncSupport

          public void configureAsyncSupport(AsyncSupportConfigurer configurer)

      Configure asynchronous request handling options.

      This implementation is empty.

      Specified by:
        `configureAsyncSupport` in interface `WebMvcConfigurer`

    - #### addArgumentResolvers

          public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)

      Add resolvers to support custom controller method argument types.

      This does not override the built-in support for resolving handler method arguments. To customize the built-in support for argument resolution, configure `RequestMappingHandlerAdapter` directly.

      This implementation is empty.

      Specified by:
        `addArgumentResolvers` in interface `WebMvcConfigurer`
      Parameters:
        `argumentResolvers` - initially an empty list

    - #### addReturnValueHandlers

          public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)

      Add handlers to support custom controller method return value types.

      Using this option does not override the built-in support for handling return values. To customize the built-in support for handling return values, configure RequestMappingHandlerAdapter directly.

      This implementation is empty.

      Specified by:
        `addReturnValueHandlers` in interface `WebMvcConfigurer`
      Parameters:
        `returnValueHandlers` - initially an empty list

    - #### configureHandlerExceptionResolvers

          public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers)

      Configure the `HandlerExceptionResolver`s to handle unresolved controller exceptions. If no resolvers are added to the list, default exception resolvers are added instead.

      This implementation is empty.

      Specified by:
        `configureHandlerExceptionResolvers` in interface `WebMvcConfigurer`
      Parameters:
        `exceptionResolvers` - initially an empty list

    - #### getMessageCodesResolver

          public MessageCodesResolver getMessageCodesResolver()

      Provide a custom `MessageCodesResolver` for building message codes from data binding and validation error codes. Leave the return value as `null` to keep the default.

      This implementation is empty.

      Specified by:
        `getMessageCodesResolver` in interface `WebMvcConfigurer`

    - #### addInterceptors

          public void addInterceptors(InterceptorRegistry registry)

      Add Spring MVC lifecycle interceptors for pre- and post-processing of controller method invocations. Interceptors can be registered to apply to all requests or be limited to a subset of URL patterns.

      This implementation is empty.

      Specified by:
        `addInterceptors` in interface `WebMvcConfigurer`

    - #### addViewControllers

          public void addViewControllers(ViewControllerRegistry registry)

      Add view controllers to create a direct mapping between a URL path and view name without the need for a controller in between.

      This implementation is empty.

      Specified by:
        `addViewControllers` in interface `WebMvcConfigurer`

    - #### addResourceHandlers

          public void addResourceHandlers(ResourceHandlerRegistry registry)

      Add handlers to serve static resources such as images, js, and, css files from specific locations under web application root, the classpath, and others.

      This implementation is empty.

      Specified by:
        `addResourceHandlers` in interface `WebMvcConfigurer`

    - #### configureDefaultServletHandling

          public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer)

      Configure a handler to delegate unhandled requests by forwarding to the Servlet container's "default" servlet. A common use case for this is when the `DispatcherServlet` is mapped to "/" thus overriding the Servlet container's default handling of static resources.

      This implementation is empty.

      Specified by:
        `configureDefaultServletHandling` in interface `WebMvcConfigurer`