Manage springmvc components
Overview
What to configure when using springmvc
-
Front controller
-
Controller mapper and adapter
- Mapper Map <Set <String>, Object>
- Set <String> storage resources
- @RequestMapper(value={“helle2”,”hello2”})
- Object Objects that store method objects and all objects of methods
- Execution method method.invoke (obj, args) Method
- Set <String> storage resources
- adapter
- @Controller
- Implement the Controller interface
- Implement the interface of HttpRequestHandler
- Mapper Map <Set <String>, Object>
-
View resolver
InternalResourceViewResolver -
File upload
-
Interceptor
Front-end controller automatic management
Find WebMvcAutoConfiguration
找到 DispatcherServletAutoConfiguration
create
registered
Automatic management of the controller [that is, custom c ontroller]
Auto scan
| --The default scan starts all the packages and their sub-packages;
If it is not under all packages and subpackages of the startup class
要使用 @CompomentScan(basePackage={“com.sxt.controller”,”com.bjsxt.controller”})
Automatic management of view resolvers
Find WebMvcAutoConfiguration
@Bean
@ConditionalOnMissingBean
public InternalResourceViewResolver defaultViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix(this.mvcProperties.getView().getPrefix());
resolver.setSuffix(this.mvcProperties.getView().getSuffix());
return resolver;
}
@Bean
@ConditionalOnBean(View.class)
@ConditionalOnMissingBean
public BeanNameViewResolver beanNameViewResolver() {
BeanNameViewResolver resolver = new BeanNameViewResolver();
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10);
return resolver;
}
@Bean
@ConditionalOnBean(ViewResolver.class)
@ConditionalOnMissingBean(name = "viewResolver", value = ContentNegotiatingViewResolver.class)
public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {
ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
resolver.setContentNegotiationManager(beanFactory.getBean(ContentNegotiationManager.class));
// ContentNegotiatingViewResolver uses all the other view resolvers to locate
// a view so it should have a high precedence
resolver.setOrder(Ordered.HIGHEST_PRECEDENCE);
return resolver;
}
Enter ContentNegotiatingViewResolver
to sum up
ContentNegotiatingViewResolver is a collector of view resolvers
As long as there are objects in the IOC container that implement the ViewResolver interface, they will be collected as ThymeleafViewResolver
View parser for file upload and download
Find MultipartAutoConfiguration
Find MultipartProperties
Access to static resources
classpath:resources/MATE-INF/resources
classpath:resources/resources
classpath:resources/static
classpath:resources/public
Message conversion
Find WebMvcAutoConfiguration
Format conversion
Welcome page configuration
Previously web.xml
<welcome-file-list>
</webcome-file-list>
Springboot default configuration is satic / i ndex.html