ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
# 27.1.1. Spring MVC自动配置 Spring Boot为Spring MVC提供的auto-configuration适用于大多数应用,并在Spring默认功能上添加了以下特性: 1. 引入`ContentNegotiatingViewResolver`和`BeanNameViewResolver` beans。 2. 对静态资源的支持,包括对WebJars的支持。 3. 自动注册`Converter`,`GenericConverter`,`Formatter` beans。 4. 对`HttpMessageConverters`的支持。 5. 自动注册`MessageCodeResolver`。 6. 对静态`index.html`的支持。 7. 对自定义`Favicon`的支持。 8. 自动使用`ConfigurableWebBindingInitializer` bean。 如果保留Spring Boot MVC特性,你只需添加其他的[MVC配置](http://docs.spring.io/spring/docs/4.3.3.RELEASE/spring-framework-reference/htmlsingle#mvc)(拦截器,格式化处理器,视图控制器等)。你可以添加自己的`WebMvcConfigurerAdapter`类型的`@Configuration`类,而不需要注解`@EnableWebMvc`。如果希望使用自定义的`RequestMappingHandlerMapping`,`RequestMappingHandlerAdapter`,或`ExceptionHandlerExceptionResolver`,你可以声明一个`WebMvcRegistrationsAdapter`实例提供这些组件。 如果想全面控制Spring MVC,你可以添加自己的`@Configuration`,并使用`@EnableWebMvc`注解。