类 WebMvcConfigurationSupport
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.context.ApplicationContextAware
- 直接已知子类:
DelegatingWebMvcConfiguration
@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:
RequestMappingHandlerMappingordered at 0 for mapping requests to annotated controller methods.HandlerMappingordered at 1 to map URL paths directly to view names.BeanNameUrlHandlerMappingordered at 2 to map URL paths to controller bean names.RouterFunctionMappingordered at 3 to map router functions.HandlerMappingordered atInteger.MAX_VALUE-1to serve static resource requests.HandlerMappingordered atInteger.MAX_VALUEto forward requests to the default servlet.
Registers these HandlerAdapters:
RequestMappingHandlerAdapterfor processing requests with annotated controller methods.HandlerFunctionAdapterfor processing requests with router functions.
HttpRequestHandler is default handler to handle HTTP request
Registers a CompositeHandlerExceptionHandler with this chain of
exception handlers:
ExceptionHandlerAnnotationExceptionHandlerfor handling exceptions throughExceptionHandlermethods.ResponseStatusExceptionHandlerfor exceptions annotated withResponseStatus.SimpleHandlerExceptionHandlerfor resolving known Infra exception types
PathMatchConfigurer.
Both the RequestMappingHandlerAdapter and the
ExceptionHandlerAnnotationExceptionHandler are configured with default
instances of the following by default:
- a
ContentNegotiationManager - a
DefaultFormattingConversionService - an
OptionalValidatorFactoryBeanif a JSR-303 implementation is available on the classpath - a range of
HttpMessageConvertersdepending on the third-party libraries available on the classpath.
- 从以下版本开始:
- 4.0 2022/1/27 23:43
- 作者:
- Rossen Stoyanchev, Brian Clozel, Sebastien Deleuze, Harry Yang
- 另请参阅:
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private AsyncSupportConfigurerprivate ContentNegotiationManagerprivate Map<String,CorsConfiguration> private static final booleanprivate static final booleanprivate static final booleanprivate static final booleanprivate static final booleanprivate static final booleanprivate static final booleanprivate List<HttpMessageConverter<?>>private PathMatchConfigurerprivate static final boolean从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport
applicationContext, log, messageSourceAccessor -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voidaddCorsMappings(CorsRegistry registry) Override this method to configure cross origin requests processing.protected final voidaddDefaultHandlerExceptionHandlers(List<HandlerExceptionHandler> handlers, AnnotationHandlerFactory handlerFactory) A method available to subclasses for adding defaultHandlerExceptionHandlers.protected final voidaddDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters) Adds a set of default HttpMessageConverter instances to the given list.protected voidaddFormatters(cn.taketoday.format.FormatterRegistry registry) Override this method to add customConverterand/orFormatterdelegates to the commonFormattingConversionService.protected voidaddInterceptors(InterceptorRegistry registry) Override this method to add Framework MVC interceptors for pre- and post-processing of controller invocation.protected voidaddResourceHandlers(ResourceHandlerRegistry registry) Override this method to add resource handlers for serving static resources.protected voidaddViewControllers(ViewControllerRegistry registry) Override this method to add view controllers.annotationHandlerFactory(cn.taketoday.beans.factory.BeanFactory beanFactory, ParameterResolvingRegistry registry, ReturnValueHandlerManager manager) coreAnnotationHandlerFactoryto create annotation-handlerReturn aBeanNameUrlHandlerMappingordered at 2 to map URL paths to controller bean names.protected voidconfigureAsyncSupport(AsyncSupportConfigurer configurer) Override this method to configure asynchronous request processing options.protected voidOverride this method to configure content negotiation.protected voidOverride this method to configure "default" Servlet handling.protected voidconfigureDefaultViewResolvers(List<ViewResolver> viewResolvers) Override this method to configure view resolution.protected voidOverride this method to configure the list ofHandlerExceptionHandlersto use.protected voidconfigureMessageConverters(List<HttpMessageConverter<?>> converters) Override this method to add customHttpMessageConvertersto use with theParameterResolvingStrategyand theReturnValueHandlerManager.protected voidconfigurePathMatch(PathMatchConfigurer configurer) Override this method to configure path matching options.protected voidconfigureViewResolvers(ViewResolverRegistry registry) Override this method to configure view resolution.Protected method for plugging in a custom subclass ofExceptionHandlerAnnotationExceptionHandler.private ContentNegotiationConfigurerprotected RequestMappingHandlerAdapterProtected method for plugging in a custom subclass ofRequestMappingHandlerAdapter.protected RequestMappingHandlerMappingProtected method for plugging in a custom subclass ofRequestMappingHandlerMapping.Return a handler mapping ordered at Integer.MAX_VALUE with a mapped default servlet handler.protected voidextendExceptionHandlers(List<HandlerExceptionHandler> handlers) Override this method to extend or modify the list ofHandlerExceptionHandlersafter it has been configured.protected voidextendMessageConverters(List<HttpMessageConverter<?>> converters) Override this method to extend or modify the list of converters after it has been configured.protected AsyncSupportConfigurerCallback for building theAsyncSupportConfigurer.protected final Map<String,CorsConfiguration> Return the registeredCorsConfigurationobjects, keyed by path pattern.protected final Object[]Provide access to the shared handler interceptors used to configureHandlerMappinginstances with.protected cn.taketoday.validation.MessageCodesResolverProvide a customMessageCodesResolverfor building message codes from data binding and validation error codes.final List<HttpMessageConverter<?>>Provides access to the sharedHttpMessageConvertersused by theParameterResolvingStrategyand theReturnValueHandlerManager.protected PathMatchConfigurerCallback for building thePathMatchConfigurer.protected cn.taketoday.validation.ValidatorOverride this method to provide a customValidator.protected WebBindingInitializergetWebBindingInitializer(cn.taketoday.format.support.FormattingConversionService mvcConversionService, cn.taketoday.validation.Validator mvcValidator) Return theWebBindingInitializerto use for initializing allWebDataBinderinstances.handlerExceptionHandler(AnnotationHandlerFactory handlerFactory) Returns aCompositeHandlerExceptionHandlercontaining a list of exception resolvers obtained either throughconfigureExceptionHandlers(java.util.List<cn.taketoday.web.HandlerExceptionHandler>)or throughaddDefaultHandlerExceptionHandlers(java.util.List<cn.taketoday.web.HandlerExceptionHandler>, cn.taketoday.web.handler.method.AnnotationHandlerFactory).Returns aHandlerFunctionAdapterfor processing requests through handler functions.protected voidprivate voidvoidinitHandlerMapping(AbstractHandlerMapping mapping) (专用程序包) static booleanprotected voidprotected voidReturn aContentNegotiationManagerinstance to use to determine requested media types in a given request.cn.taketoday.format.support.FormattingConversionServiceReturn aFormattingConversionServicefor use with annotated controllers.AResourceUrlProviderbean for use with the MVC dispatcher.mvcUriComponentsContributor(ParameterResolvingRegistry registry, cn.taketoday.format.support.FormattingConversionService conversionService) Return an instance ofCompositeUriComponentsContributorfor use withMvcUriComponentsBuilder.cn.taketoday.validation.ValidatorReturn a globalValidatorinstance for example for validating@ModelAttributeand@RequestBodymethod arguments.mvcViewResolver(ContentNegotiationManager contentNegotiationManager) Register aViewResolverCompositethat contains a chain of view resolvers to use for view resolution.(专用程序包) ParameterResolvingRegistryparameterResolvingRegistry(ParameterResolvingStrategy[] strategies, RedirectModelManager redirectModelManager, ContentNegotiationManager contentNegotiationManager) defaultParameterResolvingStrategyregistryrequestMappingHandlerAdapter(SessionManager sessionManager, RedirectModelManager redirectModelManager, WebBindingInitializer webBindingInitializer, ParameterResolvingRegistry parameterResolvingRegistry, cn.taketoday.validation.Validator validator, cn.taketoday.format.support.FormattingConversionService conversionService) Returns aRequestMappingHandlerAdapterfor processing requests through annotated controller methods.(专用程序包) RequestMappingHandlerMappingrequestMappingHandlerMapping(ContentNegotiationManager contentNegotiationManager, ParameterResolvingRegistry parameterResolvingRegistry) coreHandlerMappingto register handlerresourceHandlerMapping(NotFoundHandler notFoundHandler, ContentNegotiationManager contentNegotiationManager) Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped resource handlers.(专用程序包) ReturnValueHandlerManagerreturnValueHandlerManager(ViewReturnValueHandler viewHandler, RedirectModelManager redirectModelManager, ContentNegotiationManager contentNegotiationManager) defaultReturnValueHandlerregistryReturn aRouterFunctionMappingordered at 3 to map router functions.Return a handler mapping ordered at 1 to map URL paths directly to view names.viewReturnValueHandler(LocaleResolver localeResolver, List<ViewResolver> viewResolvers) WebAsyncManager Factory从类继承的方法 cn.taketoday.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext, unwrapContext, unwrapFactory
-
字段详细资料
-
gsonPresent
private static final boolean gsonPresent -
jsonbPresent
private static final boolean jsonbPresent -
romePresent
private static final boolean romePresent -
jackson2Present
private static final boolean jackson2Present -
jackson2SmilePresent
private static final boolean jackson2SmilePresent -
jackson2CborPresent
private static final boolean jackson2CborPresent -
jackson2XmlPresent
private static final boolean jackson2XmlPresent -
jaxb2Present
private static final boolean jaxb2Present -
requestResponseBodyAdvice
-
contentNegotiationManager
-
pathMatchConfigurer
-
messageConverters
-
corsConfigurations
-
interceptors
-
asyncSupportConfigurer
-
-
构造器详细资料
-
WebMvcConfigurationSupport
public WebMvcConfigurationSupport()
-
-
方法详细资料
-
initApplicationContext
protected void initApplicationContext()- 覆盖:
initApplicationContext在类中cn.taketoday.context.support.ApplicationObjectSupport
-
initControllerAdviceCache
private void initControllerAdviceCache() -
getMessageConverters
Provides access to the sharedHttpMessageConvertersused by theParameterResolvingStrategyand theReturnValueHandlerManager.This method cannot be overridden; use
configureMessageConverters(java.util.List<cn.taketoday.http.converter.HttpMessageConverter<?>>)instead. Also seeaddDefaultHttpMessageConverters(java.util.List<cn.taketoday.http.converter.HttpMessageConverter<?>>)for adding default message converters. -
configureMessageConverters
Override this method to add customHttpMessageConvertersto use with theParameterResolvingStrategyand theReturnValueHandlerManager.Adding converters to the list turns off the default converters that would otherwise be registered by default. Also see
addDefaultHttpMessageConverters(java.util.List<cn.taketoday.http.converter.HttpMessageConverter<?>>)for adding default message converters.- 参数:
converters- a list to add message converters to (initially an empty list)- 从以下版本开始:
- 4.0
-
extendMessageConverters
Override this method to extend or modify the list of converters after it has been configured. This may be useful for example to allow default converters to be registered and then insert a custom converter through this method.- 参数:
converters- the list of configured converters to extend- 从以下版本开始:
- 4.0
-
addDefaultHttpMessageConverters
protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters) Adds a set of default HttpMessageConverter instances to the given list. Subclasses can call this method fromconfigureMessageConverters(java.util.List<cn.taketoday.http.converter.HttpMessageConverter<?>>).- 参数:
messageConverters- the list to add the default message converters to- 从以下版本开始:
- 4.0
-
webAsyncManagerFactory
WebAsyncManager Factory -
mvcContentNegotiationManager
@Role(2) @ConditionalOnMissingBean(ContentNegotiationManager.class) public ContentNegotiationManager mvcContentNegotiationManager()Return aContentNegotiationManagerinstance to use to determine requested media types in a given request. -
createNegotiationConfigurer
-
getDefaultMediaTypes
-
configureContentNegotiation
Override this method to configure content negotiation. -
getPathMatchConfigurer
Callback for building thePathMatchConfigurer. Delegates toconfigurePathMatch(cn.taketoday.web.config.PathMatchConfigurer). -
configurePathMatch
Override this method to configure path matching options.- 另请参阅:
-
mvcViewResolver
@Nullable @Role(2) public ViewResolver mvcViewResolver(@Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager) Register aViewResolverCompositethat contains a chain of view resolvers to use for view resolution. By default this resolver is ordered at 0 unless content negotiation view resolution is used in which case the order is raised toOrdered.HIGHEST_PRECEDENCE.If no other resolvers are configured,
ViewResolverComposite.resolveViewName(String, Locale)returns null in order to allow other potentialViewResolverbeans to resolve views. -
configureDefaultViewResolvers
Override this method to configure view resolution.- 另请参阅:
-
configureViewResolvers
Override this method to configure view resolution.- 另请参阅:
-
webLocaleResolver
-
viewReturnValueHandler
@Role(2) @ConditionalOnMissingBean(ViewReturnValueHandler.class) public ViewReturnValueHandler viewReturnValueHandler(@Qualifier("webLocaleResolver") LocaleResolver localeResolver, List<ViewResolver> viewResolvers) -
returnValueHandlerManager
@Role(2) @ConditionalOnMissingBean(ReturnValueHandlerManager.class) ReturnValueHandlerManager returnValueHandlerManager(ViewReturnValueHandler viewHandler, @Nullable RedirectModelManager redirectModelManager, @Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager) defaultReturnValueHandlerregistry -
modifyReturnValueHandlerManager
-
parameterResolvingRegistry
@ConditionalOnMissingBean @Role(2) ParameterResolvingRegistry parameterResolvingRegistry(ParameterResolvingStrategy[] strategies, @Nullable RedirectModelManager redirectModelManager, @Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager) defaultParameterResolvingStrategyregistry -
modifyParameterResolvingRegistry
-
handlerExceptionHandler
@Role(2) public HandlerExceptionHandler handlerExceptionHandler(AnnotationHandlerFactory handlerFactory) Returns aCompositeHandlerExceptionHandlercontaining a list of exception resolvers obtained either throughconfigureExceptionHandlers(java.util.List<cn.taketoday.web.HandlerExceptionHandler>)or throughaddDefaultHandlerExceptionHandlers(java.util.List<cn.taketoday.web.HandlerExceptionHandler>, cn.taketoday.web.handler.method.AnnotationHandlerFactory).Note: This method cannot be made final due to CGLIB constraints. Rather than overriding it, consider overriding
configureExceptionHandlers(java.util.List<cn.taketoday.web.HandlerExceptionHandler>)which allows for providing a list of resolvers. -
configureExceptionHandlers
Override this method to configure the list ofHandlerExceptionHandlersto use.Adding resolvers to the list turns off the default resolvers that would otherwise be registered by default. Also see
addDefaultHandlerExceptionHandlers(java.util.List<cn.taketoday.web.HandlerExceptionHandler>, cn.taketoday.web.handler.method.AnnotationHandlerFactory)that can be used to add the default exception resolvers.- 参数:
handlers- a list to add exception handlers to (initially an empty list)
-
extendExceptionHandlers
Override this method to extend or modify the list ofHandlerExceptionHandlersafter it has been configured.This may be useful for example to allow default resolvers to be registered and then insert a custom one through this method.
- 参数:
handlers- the list of configured resolvers to extend.
-
addDefaultHandlerExceptionHandlers
protected final void addDefaultHandlerExceptionHandlers(List<HandlerExceptionHandler> handlers, AnnotationHandlerFactory handlerFactory) A method available to subclasses for adding defaultHandlerExceptionHandlers.Adds the following exception resolvers:
ExceptionHandlerAnnotationExceptionHandlerfor handling exceptions throughExceptionHandlermethods.ResponseStatusExceptionHandlerfor exceptions annotated withResponseStatus.SimpleHandlerExceptionHandlerfor resolving known Framework exception types
-
createAnnotationExceptionHandler
Protected method for plugging in a custom subclass ofExceptionHandlerAnnotationExceptionHandler. -
requestMappingHandlerMapping
@Role(2) @ConditionalOnMissingBean(RequestMappingHandlerMapping.class) RequestMappingHandlerMapping requestMappingHandlerMapping(@Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager, ParameterResolvingRegistry parameterResolvingRegistry) coreHandlerMappingto register handler -
createRequestMappingHandlerMapping
Protected method for plugging in a custom subclass ofRequestMappingHandlerMapping. -
annotationHandlerFactory
@ConditionalOnMissingBean @Role(2) public AnnotationHandlerFactory annotationHandlerFactory(cn.taketoday.beans.factory.BeanFactory beanFactory, ParameterResolvingRegistry registry, ReturnValueHandlerManager manager) coreAnnotationHandlerFactoryto create annotation-handler -
beanNameHandlerMapping
Return aBeanNameUrlHandlerMappingordered at 2 to map URL paths to controller bean names. -
routerFunctionMapping
Return aRouterFunctionMappingordered at 3 to map router functions. Consider overriding one of these other more fine-grained methods:addInterceptors(cn.taketoday.web.config.InterceptorRegistry)for adding handler interceptors.addCorsMappings(cn.taketoday.web.config.CorsRegistry)to configure cross origin requests processing.configureMessageConverters(java.util.List<cn.taketoday.http.converter.HttpMessageConverter<?>>)for adding custom message converters.configurePathMatch(PathMatchConfigurer)for customizing thePathPatternParser.
-
initHandlerMapping
-
resourceHandlerMapping
@Nullable @Role(2) public HandlerMapping resourceHandlerMapping(@Nullable NotFoundHandler notFoundHandler, @Qualifier("mvcContentNegotiationManager") ContentNegotiationManager contentNegotiationManager) Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped resource handlers. To configure resource handling, overrideaddResourceHandlers(cn.taketoday.web.config.ResourceHandlerRegistry). -
viewControllerHandlerMapping
Return a handler mapping ordered at 1 to map URL paths directly to view names. To configure view controllers, overrideaddViewControllers(cn.taketoday.web.config.ViewControllerRegistry). -
addViewControllers
Override this method to add view controllers.- 另请参阅:
-
defaultServletHandlerMapping
Return a handler mapping ordered at Integer.MAX_VALUE with a mapped default servlet handler. To configure "default" Servlet handling, overrideconfigureDefaultServletHandling(cn.taketoday.web.config.DefaultServletHandlerConfigurer). -
configureDefaultServletHandling
Override this method to configure "default" Servlet handling. -
addResourceHandlers
Override this method to add resource handlers for serving static resources.- 另请参阅:
-
mvcResourceUrlProvider
AResourceUrlProviderbean for use with the MVC dispatcher. -
getCorsConfigurations
Return the registeredCorsConfigurationobjects, keyed by path pattern. -
addCorsMappings
Override this method to configure cross origin requests processing.- 另请参阅:
-
getInterceptors
Provide access to the shared handler interceptors used to configureHandlerMappinginstances with.This method cannot be overridden; use
addInterceptors(cn.taketoday.web.config.InterceptorRegistry)instead. -
addInterceptors
Override this method to add Framework MVC interceptors for pre- and post-processing of controller invocation.- 另请参阅:
-
mvcConversionService
@Role(2) public cn.taketoday.format.support.FormattingConversionService mvcConversionService()Return aFormattingConversionServicefor use with annotated controllers.See
addFormatters(cn.taketoday.format.FormatterRegistry)as an alternative to overriding this method. -
addFormatters
protected void addFormatters(cn.taketoday.format.FormatterRegistry registry) Override this method to add customConverterand/orFormatterdelegates to the commonFormattingConversionService.- 另请参阅:
-
requestMappingHandlerAdapter
@Role(2) public RequestMappingHandlerAdapter requestMappingHandlerAdapter(@Nullable SessionManager sessionManager, @Nullable RedirectModelManager redirectModelManager, @Nullable WebBindingInitializer webBindingInitializer, ParameterResolvingRegistry parameterResolvingRegistry, @Qualifier("mvcValidator") cn.taketoday.validation.Validator validator, @Qualifier("mvcConversionService") cn.taketoday.format.support.FormattingConversionService conversionService) Returns aRequestMappingHandlerAdapterfor processing requests through annotated controller methods. Consider overriding one of these other more fine-grained methods:modifyParameterResolvingRegistry(ParameterResolvingRegistry)for adding custom argument resolvers.modifyReturnValueHandlerManager(ReturnValueHandlerManager)for adding custom return value handlers.configureMessageConverters(java.util.List<cn.taketoday.http.converter.HttpMessageConverter<?>>)for adding custom message converters.
-
createRequestMappingHandlerAdapter
Protected method for plugging in a custom subclass ofRequestMappingHandlerAdapter. -
handlerFunctionAdapter
Returns aHandlerFunctionAdapterfor processing requests through handler functions. -
getWebBindingInitializer
protected WebBindingInitializer getWebBindingInitializer(cn.taketoday.format.support.FormattingConversionService mvcConversionService, cn.taketoday.validation.Validator mvcValidator) Return theWebBindingInitializerto use for initializing allWebDataBinderinstances. -
mvcValidator
@Role(2) public cn.taketoday.validation.Validator mvcValidator()Return a globalValidatorinstance for example for validating@ModelAttributeand@RequestBodymethod arguments. Delegates togetValidator()first and if that returnsnullchecks the classpath for the presence of a JSR-303 implementations before creating aOptionalValidatorFactoryBean.If a JSR-303 implementation is not available, a no-opValidatoris returned. -
getMessageCodesResolver
@Nullable protected cn.taketoday.validation.MessageCodesResolver getMessageCodesResolver()Provide a customMessageCodesResolverfor building message codes from data binding and validation error codes. Leave the return value asnullto keep the default. -
getValidator
@Nullable protected cn.taketoday.validation.Validator getValidator()Override this method to provide a customValidator. -
getAsyncSupportConfigurer
Callback for building theAsyncSupportConfigurer. Delegates toconfigureAsyncSupport(AsyncSupportConfigurer). -
configureAsyncSupport
Override this method to configure asynchronous request processing options.- 另请参阅:
-
mvcUriComponentsContributor
@Role(2) public CompositeUriComponentsContributor mvcUriComponentsContributor(ParameterResolvingRegistry registry, @Qualifier("mvcConversionService") cn.taketoday.format.support.FormattingConversionService conversionService) Return an instance ofCompositeUriComponentsContributorfor use withMvcUriComponentsBuilder. -
isPresent
-