@EnableWebMvc to an
application @Configuration class. An alternative more
advanced option is to extend directly from this class and override methods as
necessary, remembering to add @Configuration to the
subclass and @Bean to overridden @Bean methods.
For more details see the javadoc of @EnableWebMvc.
This class registers the following HandlerMappings:
RouterFunctionMapping
ordered at -1 to map router functions.
RequestMappingHandlerMapping
ordered at 0 for mapping requests to annotated controller methods.
HandlerMapping
ordered at 1 to map URL paths directly to view names.
BeanNameUrlHandlerMapping
ordered at 2 to map URL paths to controller bean names.
HandlerMapping
ordered at Integer.MAX_VALUE-1 to serve static resource requests.
HandlerMapping
ordered at Integer.MAX_VALUE to forward requests to the default servlet.
Registers these HandlerAdapters:
RequestMappingHandlerAdapter
for processing requests with annotated controller methods.
HttpRequestHandlerAdapter
for processing requests with HttpRequestHandlers.
SimpleControllerHandlerAdapter
for processing requests with interface-based Controllers.
HandlerFunctionAdapter
for processing requests with router functions.
Registers a HandlerExceptionResolverComposite with this chain of
exception resolvers:
ExceptionHandlerExceptionResolver for handling exceptions through
org.springframework.web.bind.annotation.ExceptionHandler methods.
ResponseStatusExceptionResolver for exceptions annotated with
org.springframework.web.bind.annotation.ResponseStatus .
DefaultHandlerExceptionResolver for resolving known Spring
exception types
Registers an AntPathMatcher and a UrlPathHelper
to be used by:
RequestMappingHandlerMapping,
HandlerMapping for ViewControllers
HandlerMapping for serving resources
PathMatchConfigurer.
Both the RequestMappingHandlerAdapter and the
ExceptionHandlerExceptionResolver are configured with default
instances of the following by default:
ContentNegotiationManager
DefaultFormattingConversionService
org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean
if a JSR-303 implementation is available on the classpath
HttpMessageConverters depending on the third-party
libraries available on the classpath.
EnableWebMvc, WebMvcConfigurer
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private ApplicationContext | |
| private List | |
| private AsyncSupportConfigurer | |
| private ContentNegotiationManager | |
| private Map | |
| private static final boolean | |
| private List | |
| private static final boolean | |
| private static final boolean | |
| private static final boolean | |
| private static final boolean | |
| private static final boolean | |
| private static final boolean | |
| private static final boolean | |
| private static final boolean | |
| private static final boolean | |
| private List | |
| private PathMatchConfigurer | |
| private List | |
| private static final boolean | |
| private ServletContext |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | addArgumentResolvers(List<HandlerMethodArgumentResolver>
the list of custom converters (initially an empty list) argumentResolvers)Add custom |
| protected void | addCorsMappings(CorsRegistry registry)
Override this method to configure cross-origin requests processing. |
| protected final void | addDefaultHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers, ContentNegotiationManager mvcContentNegotiationManager)
A method available to subclasses for adding default
|
| protected final void | addDefaultHttpMessageConverters(List<HttpMessageConverter<?>>
the list to add the default message converters to messageConverters)Adds a set of default HttpMessageConverter instances to the given list. |
| protected void | addFormatters(FormatterRegistry registry)
Override this method to add custom |
| protected void | addInterceptors(InterceptorRegistry registry)
Override this method to add Spring MVC interceptors for pre- and post-processing of controller invocation. |
| protected void | addResourceHandlers(ResourceHandlerRegistry registry)
Override this method to add resource handlers for serving static resources. |
| protected void | addReturnValueHandlers(List<HandlerMethodReturnValueHandler>
the list of custom handlers (initially an empty list) returnValueHandlers)Add custom |
| protected void | |
| public BeanNameUrlHandlerMapping | beanNameHandlerMapping(FormattingConversionService conversionService, ResourceUrlProvider resourceUrlProvider)
Return a |
| protected void | configureAsyncSupport(AsyncSupportConfigurer configurer)
Override this method to configure asynchronous request processing options. |
| protected void | configureContentNegotiation(ContentNegotiationConfigurer configurer)
Override this method to configure content negotiation. |
| protected void | configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer)
Override this method to configure "default" Servlet handling. |
| protected void | configureHandlerExceptionResolvers(List<HandlerExceptionResolver>
a list to add exception resolvers to (initially an empty list) exceptionResolvers)Override this method to configure the list of
|
| protected void | configureMessageConverters(List<HttpMessageConverter<?>>
a list to add message converters to (initially an empty list) converters)Override this method to add custom |
| protected void | configurePathMatch(PathMatchConfigurer configurer)
Override this method to configure path matching options. |
| protected void | configureViewResolvers(ViewResolverRegistry registry)
Override this method to configure view resolution. |
| protected ExceptionHandlerExceptionResolver | createExceptionHandlerExceptionResolver()
Protected method for plugging in a custom subclass of
|
| protected RequestMappingHandlerAdapter | createRequestMappingHandlerAdapter()
Protected method for plugging in a custom subclass of
|
| protected RequestMappingHandlerMapping | createRequestMappingHandlerMapping()
Protected method for plugging in a custom subclass of
|
| public HandlerMapping | defaultServletHandlerMapping()
Return a handler mapping ordered at Integer.MAX_VALUE with a mapped default servlet handler. |
| protected void | extendHandlerExceptionResolvers(List<HandlerExceptionResolver>
the list of configured resolvers to extend. exceptionResolvers)Override this method to extend or modify the list of
|
| protected void | extendMessageConverters(List<HttpMessageConverter<?>>
the list of configured converters to extend converters)Override this method to extend or modify the list of converters after it has been configured. |
| public FlashMapManager | |
| public final ApplicationContext | |
| protected final List | getArgumentResolvers()
Provide access to the shared custom argument resolvers used by the
|
| protected AsyncSupportConfigurer | |
| protected ConfigurableWebBindingInitializer | getConfigurableWebBindingInitializer(FormattingConversionService mvcConversionService, Validator mvcValidator)
Return the |
| protected final Map | |
| protected Map | |
| protected final Object[] | getInterceptors(FormattingConversionService mvcConversionService, ResourceUrlProvider mvcResourceUrlProvider)
Provide access to the shared handler interceptors used to configure
|
| protected MessageCodesResolver | |
| protected final List | getMessageConverters()
Provides access to the shared |
| protected PathMatchConfigurer | |
| protected final List | getReturnValueHandlers()
Provide access to the shared return value handlers used by the
|
| public final ServletContext | |
| protected Validator | |
| public HandlerExceptionResolver | handlerExceptionResolver(ContentNegotiationManager contentNegotiationManager)
Returns a |
| public HandlerFunctionAdapter | handlerFunctionAdapter()
Returns a |
| public HttpRequestHandlerAdapter | httpRequestHandlerAdapter()
Returns a |
| private void | initHandlerMapping(AbstractHandlerMapping mapping, FormattingConversionService conversionService, ResourceUrlProvider resourceUrlProvider)
|
| public LocaleResolver | |
| public ContentNegotiationManager | mvcContentNegotiationManager()
Return a |
| public FormattingConversionService | |
| public HandlerMappingIntrospector | |
| public PathMatcher | mvcPathMatcher()
Return a global |
| public PathPatternParser | mvcPatternParser()
Return a global |
| public ResourceUrlProvider | |
| public CompositeUriComponentsContributor | mvcUriComponentsContributor(FormattingConversionService conversionService, RequestMappingHandlerAdapter requestMappingHandlerAdapter)
Return an instance of |
| public UrlPathHelper | mvcUrlPathHelper()
Return a global |
| public Validator | mvcValidator()
Return a global |
| public ViewResolver | mvcViewResolver(ContentNegotiationManager contentNegotiationManager)
Register a |
| public RequestMappingHandlerAdapter | requestMappingHandlerAdapter(ContentNegotiationManager contentNegotiationManager, FormattingConversionService conversionService, Validator validator)
Returns a |
| public RequestMappingHandlerMapping | requestMappingHandlerMapping(ContentNegotiationManager contentNegotiationManager, FormattingConversionService conversionService, ResourceUrlProvider resourceUrlProvider)
Return a |
| public HandlerMapping | resourceHandlerMapping(ContentNegotiationManager contentNegotiationManager, FormattingConversionService conversionService, ResourceUrlProvider resourceUrlProvider)
Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped resource handlers. |
| public RouterFunctionMapping | routerFunctionMapping(FormattingConversionService conversionService, ResourceUrlProvider resourceUrlProvider)
Return a |
| public void | setApplicationContext(ApplicationContext
the ApplicationContext object to be used by this object applicationContext)Implements org. Set the Spring |
| public void | setServletContext(ServletContext
the ServletContext object to be used by this object servletContext)Implements org. Set the |
| public SimpleControllerHandlerAdapter | simpleControllerHandlerAdapter()
Returns a |
| public ThemeResolver | |
| public HandlerMapping | viewControllerHandlerMapping(FormattingConversionService conversionService, ResourceUrlProvider resourceUrlProvider)
Return a handler mapping ordered at 1 to map URL paths directly to view names. |
| public RequestToViewNameTranslator |