一、问题引入
我们在SSM中使用SpringMVC的时候,需要由我们自己写SpringMVC的配置文件,需要用到什么就要自己配什么,配置起来也特别的麻烦。我们使用SpringBoot的时候没有进行配置,直接就能进行使用,这是为什么呢?
这是因为SpringBoot为我们自动配置好了SpringMVC
1)、我们首先参照官网来看一下关于SpringMVC的自动配置
SpringBoot官网对于SpringMvc的自动配置描述
Spring MVC Auto-configuration
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.
-
- 自动配置了ViewResolver(视图解析器:根据方法的返回值得到视图对象(View),视图对象决定如何渲染(转发?重定向?))
- ContentNegotiatingViewResolver:组合所有的视图解析器的;
-
- ==如何定制:我们可以自己给容器中添加一个视图解析器;自动的将其组合进来
-
Support for serving static resources, including support for WebJars (covered later in this document)).
静态资源文件夹路径.webjars
- Automatic registration of Converter, GenericConverter, and Formatter beans.
自动注册了Convert