-
缺省配置类 :
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-09-11 17:25:24 发布
本文详细解析了SpringMVC的缺省配置类WebMvcConfigurationSupport的功能,包括其提供的多个核心bean,如RequestMappingHandlerMapping和HandlerExceptionResolver等。同时介绍了如何通过@EnableWebMvc注解启用这些配置,以及如何使用DelegatingWebMvcConfiguration进行定制。
1055

被折叠的 条评论
为什么被折叠?



