-
缺省配置类 :
WebMvcConfigurationSupport
该类提供缺省的Spring MVC
配置,主要表现为定义如下bean
供Spring MVC
运行时使用 :RequestMappingHandlerMapping requestMappingHandlerMapping()
PathMatcher mvcPathMatcher()
UrlPathHelper mvcUrlPathHelper()
ContentNegotiationManager mvcContentNegotiationManager()
HandlerMapping viewControllerHandlerMapping()
BeanNameUrlHandlerMapping beanNameHandlerMapping()
HandlerMapping resourceHandlerMapping()
ResourceUrlProvider mvcResourceUrlProvider()
HandlerMapping defaultServletHandlerMapping()
RequestMappingHandlerAdapter requestMappingHandlerAdapter()
FormattingConversionService mvcConversionService()
Validator mvcValidator()
CompositeUriComponentsContributor mvcUriComponentsContributor()
HttpRequestHandlerAdapter httpRequestHandlerAdapter()
SimpleControllerHandlerAdapter simpleControllerHandlerAdapter()
HandlerExceptionResolver handlerExceptionResolver()
ViewResolver mvcViewResolver()
HandlerMappingIntrospector mvcHandlerMappingIntrospector()
-
缺省
Spring MVC
配置引入注解 :@EnableWebMvc
使用该注解会引入缺省的Spring MVC
配置。该注解通常用在某个配置类上,也就是结合@Configuration
使用。 -
Spring MVC
配置定制器接口定义 :WebMvcConfigurer
让某些配置类变成Spring MVC
配置的一个定制器。用于被使用@Configuration
注解的配置类实现,从而使该配置类成为一个Spring MVC
配置定制器。 -
Spring MVC
配置委托定制配置类 :DelegatingWebMvcConfiguration
DelegatingWebMvcConfiguration
继承自WebMvcConfigurationSupport
,也就是说它自身相当于WebMvcConfigurationSupport
用于提供Spring MVC
缺省配置。另外
DelegatingWebMvcConfiguration
本身也是配置类(使用了注解@Configuration
),也会被注入一组WebMvcConfigurer
对象,这些对象通常来自开发人员或者框架提供的WebMvcConfigurer
实现类:使用注解@Configuration
的配置类,同时实现了接口WebMvcConfigurer
。来自框架的WebMvcConfigurer
实现类的例子比如SpringDataWebConfiguration
。DelegatingWebMvcConfiguration
会结合Spring MVC
缺省配置和所注入的WebMvcConfigurer
配置类合成最终运行时使用的Spring MVC
配置。
Spring MVC Java配置有关的类/注解
最新推荐文章于 2023-04-12 08:30:00 发布