接口 WebMvcConfigurer
- 所有已知实现类:
CompositeWebMvcConfigurer
@EnableWebMvc.
@EnableWebMvc-annotated configuration classes may implement
this interface to be called back and given a chance to customize the
default configuration.
- 从以下版本开始:
- 2019-05-17 17:46
- 作者:
- Harry Yang
-
方法概要
修饰符和类型方法说明default voidaddCorsMappings(CorsRegistry registry) Configure "global" cross-origin request processing.default voidaddFormatters(cn.taketoday.format.FormatterRegistry registry) AddConvertersandFormattersin addition to the ones registered by default.default voidaddInterceptors(InterceptorRegistry registry) Add MVC lifecycle interceptors for pre- and post-processing of controller method invocations and resource handler requests.default voidaddResourceHandlers(ResourceHandlerRegistry registry) Configure staticResourcedefault voidaddViewControllers(ViewControllerRegistry registry) Configure simple automated controllers pre-configured with the response status code and/or a view to render the response body.default voidconfigureAsyncSupport(AsyncSupportConfigurer configurer) Configure asynchronous request handling options.default voidConfigure content negotiation options.default voidOverride this method to configure "default" Servlet handling.default voidConfigureHandlerExceptionHandlerdefault voidconfigureHandlerRegistry(List<HandlerMapping> handlerRegistries) ConfigureHandlerMappingdefault voidconfigureMessageConverters(List<HttpMessageConverter<?>> converters) Configure theHttpMessageConverters for reading from the request body and for writing to the response body.default voidconfigureParameterResolving(ParameterResolvingRegistry registry, ParameterResolvingStrategies customizedStrategies) ConfigureParameterResolvingStrategydefault voidconfigureParameterResolving(ParameterResolvingStrategies customizedStrategies) ConfigureParameterResolvingStrategydefault voidconfigurePathMatch(PathMatchConfigurer configurer) Help with configuringHandlerMappingpath matching options such as whether to use parsedPathPatternsor String pattern matching withPathMatcher, whether to match trailing slashes, and more.default voidconfigureViewResolvers(ViewResolverRegistry registry) Configure view resolvers to translate String-based view names returned from controllers into concreteViewimplementations to perform rendering with.default voidextendExceptionHandlers(List<HandlerExceptionHandler> handlers) Override this method to extend or modify the list ofHandlerExceptionHandlersafter it has been configured.default voidextendMessageConverters(List<HttpMessageConverter<?>> converters) Extend or modify the list of converters after it has been, eitherconfiguredor initialized with a default list.default cn.taketoday.validation.ValidatorProvide a customValidatorinstead of the one created by default.default voidConfigureReturnValueHandler
-
方法详细资料
-
configureParameterResolving
ConfigureParameterResolvingStrategy- 参数:
customizedStrategies-ParameterResolvingStrategyregistry
-
configureParameterResolving
default void configureParameterResolving(ParameterResolvingRegistry registry, ParameterResolvingStrategies customizedStrategies) ConfigureParameterResolvingStrategyuser can add
ParameterResolvingStrategytoresolvingStrategiesor useParameterResolvingRegistry.getCustomizedStrategies()or useParameterResolvingRegistry.getDefaultStrategies()- 参数:
customizedStrategies-ParameterResolvingStrategyregistry- 从以下版本开始:
- 4.0
- 另请参阅:
-
modifyReturnValueHandlerManager
ConfigureReturnValueHandler- 参数:
manager-ReturnValueHandlerregistry- 另请参阅:
-
addResourceHandlers
Configure staticResource- 参数:
registry-ResourceHandlerRegistry
-
configureHandlerRegistry
ConfigureHandlerMapping- 参数:
handlerRegistries-HandlerMappings- 从以下版本开始:
- 2.3.7
-
configureDefaultServletHandling
Override this method to configure "default" Servlet handling.- 从以下版本开始:
- 4.0
- 另请参阅:
-
configureExceptionHandlers
ConfigureHandlerExceptionHandlerOverride this method to configure the list of
HandlerExceptionHandlersto use.Adding handlers to the list turns off the default resolvers that would otherwise be registered by default.
- 参数:
handlers- a list to add exception handlers to (initially an empty list)- 从以下版本开始:
- 3.0
-
extendExceptionHandlers
Override this method to extend or modify the list ofHandlerExceptionHandlersafter it has been configured.This may be useful for example to allow default handlers to be registered and then insert a custom one through this method.
- 参数:
handlers- the list of configured resolvers to extend.- 从以下版本开始:
- 4.0
-
configureContentNegotiation
Configure content negotiation options.- 从以下版本开始:
- 4.0
-
configureViewResolvers
Configure view resolvers to translate String-based view names returned from controllers into concreteViewimplementations to perform rendering with.- 从以下版本开始:
- 4.0
-
configurePathMatch
Help with configuringHandlerMappingpath matching options such as whether to use parsedPathPatternsor String pattern matching withPathMatcher, whether to match trailing slashes, and more.- 从以下版本开始:
- 4.0
- 另请参阅:
-
configureMessageConverters
Configure theHttpMessageConverters for reading from the request body and for writing to the response body.By default, all built-in converters are configured as long as the corresponding 3rd party libraries such Jackson JSON, JAXB2, and others are present on the classpath.
Note that use of this method turns off default converter registration. However, in a Infra application the
WebMvcAutoConfigurationadds anyHttpMessageConverterbeans as well as default converters. Hence, in a Infra application useHttpMessageConvertersAlternatively, for any scenario, useextendMessageConverters(java.util.List)to modify the configured list of message converters.- 参数:
converters- initially an empty list of converters- 从以下版本开始:
- 4.0
-
extendMessageConverters
Extend or modify the list of converters after it has been, eitherconfiguredor initialized with a default list.Note that the order of converter registration is important. Especially in cases where clients accept
MediaType.ALLthe converters configured earlier will be preferred.- 参数:
converters- the list of configured converters to be extended- 从以下版本开始:
- 4.0
-
addFormatters
default void addFormatters(cn.taketoday.format.FormatterRegistry registry) AddConvertersandFormattersin addition to the ones registered by default.- 从以下版本开始:
- 4.0
-
addInterceptors
Add MVC lifecycle interceptors for pre- and post-processing of controller method invocations and resource handler requests. Interceptors can be registered to apply to all requests or be limited to a subset of URL patterns.- 从以下版本开始:
- 4.0
-
addCorsMappings
Configure "global" cross-origin request processing. The configured CORS mappings apply to annotated controllers, functional endpoints, and static resources.Annotated controllers can further declare more fine-grained config via
@CrossOrigin. In such cases "global" CORS configuration declared here iscombinedwith local CORS configuration defined on a controller method.- 从以下版本开始:
- 4.0
- 另请参阅:
-
addViewControllers
Configure simple automated controllers pre-configured with the response status code and/or a view to render the response body. This is useful in cases where there is no need for custom controller logic -- e.g. render a home page, perform simple site URL redirects, return a 404 status with HTML content, a 204 with no content, and more.- 从以下版本开始:
- 4.0
- 另请参阅:
-
getValidator
@Nullable default cn.taketoday.validation.Validator getValidator()Provide a customValidatorinstead of the one created by default. The default implementation, assuming JSR-303 is on the classpath, is:OptionalValidatorFactoryBean. Leave the return value asnullto keep the default.- 从以下版本开始:
- 4.0
-
configureAsyncSupport
Configure asynchronous request handling options.- 从以下版本开始:
- 4.0
-