首页
学习
活动
专区
圈层
工具
发布
25 篇文章
1
SpringBoot2.x系列教程(五十九)SpringBoot实现国际化i18n功能
2
SpringBoot2.x系列教程(五十五)Mybatis反向生成Java代码
3
SpringBoot2.x系列教程(四十四)WebSocket基础知识简介
4
SpringBoot2.x系列教程(四十三)SpringBoot整合Swagger2
5
SpringBoot2.x系列教程(五十)Spring Boot Idea中热部署(自动刷新)
6
SpringBoot2.x系列教程(四十二)SpringBoot中构建RESTful服务
7
SpringBoot2.x系列教程(三十八)SpringBoot配置Https访问
8
SpringBoot2.x系列教程(三十六)SpringBoot之Tomcat配置
9
SpringBoot2.x系列教程(三十四)Thymeleaf自动配置源码解析
10
SpringBoot2.x系列教程(三十三)Thymeleaf手动渲染实例讲解
11
SpringBoot2.x系列教程(三十二)Thymeleaf资源导入及公共布局
12
SpringBoot2.x系列教程(三十一)Thymeleaf的基本使用
13
SpringBoot2.x系列教程(三十)SpringBoot集成Thymeleaf
14
SpringBoot2.x系列教程(二十九)freemarker自动配置源码解析
15
SpringBoot2.x系列教程(二十八)freemarker基本语法使用
16
SpringBoot2.x系列教程(二十六)Springboot集成freemarker
17
SpringBoot2.x系列教程(二十五)Jsp中使用jstl和引入静态资源
18
SpringBoot2.x系列教程(二十三)SpringBoot集成Jsp
19
SpringBoot2.x系列教程(二十二)简单参数校验及统一异常处理
20
SpringBoot2.x系列教程(二十)自定义参数校验注解
21
SpringBoot2.x系列教程(十三)Jackson命名策略及自定义序列化
22
SpringBoot2.x系列教程(十)Json之基础使用详解
23
SpringBoot2.x系列教程(十九)Validation数据校验基础使用
24
SpringBoot2.x系列教程(九)基于Postman的RESTful接口调用
25
SpringBoot2.x系列教程(八)SpringBoot常用注解汇总

SpringBoot2.x系列教程(三十四)Thymeleaf自动配置源码解析

在之前的章节中我们已经学习了SpringBoot中Thymeleaf的基本使用,按照老规矩,我们最后来看一下Thymeleaf在SpringBoot中的自动配置相关源码。

关于源码阅读依旧重点给大家介绍基本的类及相关的实现思路,达到抛砖引玉的效果。而相关Thymeleaf底层的实现,大家可自行阅读Thymeleaf相关源码。

首先看来与application.properties文件绑定的配置类的相关源代码,在此只展示常用的一些配置属性,具体定义有可以参考前面文章中关于Thymeleaf的application.properties配置说明。

代码语言:javascript
复制
@ConfigurationProperties(prefix = "spring.thymeleaf")
public class ThymeleafProperties {
    /**
	 * 默认编码字符UTF8
	 */
	private static final Charset DEFAULT_ENCODING = StandardCharsets.UTF_8;

    /**
	 * 模板文件默认存放路径
	 */
	public static final String DEFAULT_PREFIX = "classpath:/templates/";

    /**
	 * 模板文件默认后缀
	 */
	public static final String DEFAULT_SUFFIX = ".html";

	/**
	 * 是否检查模板合法性
	 */
	private boolean checkTemplate = true;

	/**
	 * 是否坚持模板位置是否存在
	 */
	private boolean checkTemplateLocation = true;

	/**
	 * 构建URL时前缀
	 */
	private String prefix = DEFAULT_PREFIX;

	/**
	 * 构建URL时后缀
	 */
	private String suffix = DEFAULT_SUFFIX;

	/**
	 * 模板对应的模式,具体定义位于TemplateMode枚举类中
	 */
	private
下一篇
举报
领券