javascript
[SpringBoot2]web场景_SpringBoot2_SpringMVC自动配置概览
Spring Boot provides auto-configuration for Spring MVC that works well with most applications.(大多場景我們都無需自定義配置)
The auto-configuration adds the following features on top of Spring’s defaults:
● Inclusion of ContentNegotiatingViewResolver and BeanNameViewResolver beans.
○ 內容協(xié)商視圖解析器和BeanName視圖解析器
● Support for serving static resources, including support for WebJars (covered later in this document)).
○ 靜態(tài)資源(包括webjars)
● Automatic registration of Converter, GenericConverter, and Formatter beans.
○ 自動注冊 Converter,GenericConverter,Formatter
● Support for HttpMessageConverters (covered later in this document).
○ 支持 HttpMessageConverters (后來我們配合內容協(xié)商理解原理)
● Automatic registration of MessageCodesResolver (covered later in this document).
○ 自動注冊 MessageCodesResolver (國際化用)
● Static index.html support.
○ 靜態(tài)index.html 頁支持
● Custom Favicon support (covered later in this document).
○ 自定義 Favicon
● Automatic use of a ConfigurableWebBindingInitializer bean (covered later in this document).
○ 自動使用 ConfigurableWebBindingInitializer ,(DataBinder負責將請求數據綁定到JavaBean上)
If you want to keep those Spring Boot MVC customizations and make more MVC customizations (interceptors, formatters, view controllers, and other features), you can add your own @Configuration class of type WebMvcConfigurer but without @EnableWebMvc.
不用@EnableWebMvc注解。使用 @Configuration + WebMvcConfigurer 自定義規(guī)則
If you want to provide custom instances of
RequestMappingHandlerMapping, RequestMappingHandlerAdapter, or
ExceptionHandlerExceptionResolver, and still keep the Spring Boot MVC
customizations, you can declare a bean of type WebMvcRegistrations and
use it to provide custom instances of those components. 聲明
WebMvcRegistrations 改變默認底層組件
If you want to take complete control of Spring MVC, you can add your
own @Configuration annotated with @EnableWebMvc, or alternatively add
your own @Configuration-annotated DelegatingWebMvcConfiguration as
described in the Javadoc of @EnableWebMvc. 使用
@EnableWebMvc+@Configuration+DelegatingWebMvcConfiguration
全面接管SpringMVC
總結
以上是生活随笔為你收集整理的[SpringBoot2]web场景_SpringBoot2_SpringMVC自动配置概览的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [SpringBoot2]yaml
- 下一篇: [SpringBoot2]web场景_静