接口 WebMvcConfigurer

所有已知实现类:
CompositeWebMvcConfigurer

public interface WebMvcConfigurer
Defines callback methods to customize the Java-based configuration for framework enabled via @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
  • 方法详细资料

    • configureParameterResolving

      default void configureParameterResolving(ParameterResolvingStrategies customizedStrategies)
      参数:
      customizedStrategies - ParameterResolvingStrategy registry
    • configureParameterResolving

      default void configureParameterResolving(ParameterResolvingRegistry registry, ParameterResolvingStrategies customizedStrategies)
      参数:
      customizedStrategies - ParameterResolvingStrategy registry
      从以下版本开始:
      4.0
      另请参阅:
    • modifyReturnValueHandlerManager

      default void modifyReturnValueHandlerManager(ReturnValueHandlerManager manager)
      参数:
      manager - ReturnValueHandler registry
      另请参阅:
    • addResourceHandlers

      default void addResourceHandlers(ResourceHandlerRegistry registry)
      Configure static Resource
      参数:
      registry - ResourceHandlerRegistry
    • configureHandlerRegistry

      default void configureHandlerRegistry(List<HandlerMapping> handlerRegistries)
      Configure HandlerMapping
      参数:
      handlerRegistries - HandlerMappings
      从以下版本开始:
      2.3.7
    • configureDefaultServletHandling

      default void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer)
      Override this method to configure "default" Servlet handling.
      从以下版本开始:
      4.0
      另请参阅:
    • configureExceptionHandlers

      default void configureExceptionHandlers(List<HandlerExceptionHandler> handlers)
      Configure HandlerExceptionHandler

      Override this method to configure the list of HandlerExceptionHandlers to 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

      default void extendExceptionHandlers(List<HandlerExceptionHandler> handlers)
      Override this method to extend or modify the list of HandlerExceptionHandlers after 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

      default void configureContentNegotiation(ContentNegotiationConfigurer configurer)
      Configure content negotiation options.
      从以下版本开始:
      4.0
    • configureViewResolvers

      default void configureViewResolvers(ViewResolverRegistry registry)
      Configure view resolvers to translate String-based view names returned from controllers into concrete View implementations to perform rendering with.
      从以下版本开始:
      4.0
    • configurePathMatch

      default void configurePathMatch(PathMatchConfigurer configurer)
      Help with configuring HandlerMapping path matching options such as whether to use parsed PathPatterns or String pattern matching with PathMatcher, whether to match trailing slashes, and more.
      从以下版本开始:
      4.0
      另请参阅:
    • configureMessageConverters

      default void configureMessageConverters(List<HttpMessageConverter<?>> converters)
      Configure the HttpMessageConverters 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 WebMvcAutoConfiguration adds any HttpMessageConverter beans as well as default converters. Hence, in a Infra application use HttpMessageConverters Alternatively, for any scenario, use extendMessageConverters(java.util.List) to modify the configured list of message converters.

      参数:
      converters - initially an empty list of converters
      从以下版本开始:
      4.0
    • extendMessageConverters

      default void extendMessageConverters(List<HttpMessageConverter<?>> converters)
      Extend or modify the list of converters after it has been, either configured or initialized with a default list.

      Note that the order of converter registration is important. Especially in cases where clients accept MediaType.ALL the 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)
      Add Converters and Formatters in addition to the ones registered by default.
      从以下版本开始:
      4.0
    • addInterceptors

      default void addInterceptors(InterceptorRegistry registry)
      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

      default void addCorsMappings(CorsRegistry registry)
      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 is combined with local CORS configuration defined on a controller method.

      从以下版本开始:
      4.0
      另请参阅:
    • addViewControllers

      default void addViewControllers(ViewControllerRegistry registry)
      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 custom Validator instead of the one created by default. The default implementation, assuming JSR-303 is on the classpath, is: OptionalValidatorFactoryBean. Leave the return value as null to keep the default.
      从以下版本开始:
      4.0
    • configureAsyncSupport

      default void configureAsyncSupport(AsyncSupportConfigurer configurer)
      Configure asynchronous request handling options.
      从以下版本开始:
      4.0