文章目录
- 自动配置
 - 默认效果
 - WebMvcAutoConfiguration
 - WebMvcConfigurer接口
 - 静态资源访问
 - 首页
 - Favicon
 - 缓存
 
- 自定义静态资源路径
 - 1、配置方式
 - 2、代码方式
 
- 路径匹配规则
 - 内容协商
 - 默认支持json
 - 配置支持xml
 - 内容协商原理
 - 自定义支持ymal
 
- 模板引擎
 - 模板引擎Thymeleaf整合
 - 基础语法
 - 遍历
 - 判断
 - 属性优先级
 - 变量选择
 - 模板抽取
 
- 开发小技巧
 - 国际化
 - 异常处理
 - 全局
 - 原理
 
- 嵌入式容器
 - 切换服务器
 
- 全面接管SpringMVC
 - 新特性problemdetails
 - 函数编程
 
自动配置

 
 
默认效果

 
WebMvcAutoConfiguration


WebMvcConfigurer接口

静态资源访问
public void addResourceHandlers(ResourceHandlerRegistry registry) {
            if (!this.resourceProperties.isAddMappings()) {
                logger.debug("Default resource handling disabled");
            } else {
                this.addResourceHandler(registry, this.mvcProperties.getWebjarsPathPattern(), "classpath:/META-INF/resources/webjars/");
                this.addResourceHandler(registry, this.mvcProperties.getStaticPathPattern(), (registration) -> {
                    registration.addResourceLocations(this.resourceProperties.getStaticLocations());
                    if (this.servletContext != null) {
                        ServletContextResource resource = new ServletContextResource(this.servletContext, "/");
                        registration.addResourceLocations(new Resource[]{resource});
                    }
                });
            }
        }
 

首页

Favicon

缓存

自定义静态资源路径
1、配置方式

2、代码方式

 
路径匹配规则


内容协商

 
 
默认支持json
配置支持xml
引入支持xml的pom依赖文件
 
实体类添加xml支持注解
 
 
内容协商原理




自定义支持ymal

 

HttpMessageConverter示例写法
 
模板引擎
模板引擎Thymeleaf整合

 

基础语法

 
 
遍历

判断

属性优先级

变量选择

模板抽取



 
开发小技巧

国际化


异常处理
全局

原理

 
嵌入式容器

 
 
 
切换服务器


全面接管SpringMVC

 
 
 
 
新特性problemdetails

 
函数编程





















