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

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

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

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

@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

你可能感兴趣的:(SpringBoot2.x系列教程(三十四)Thymeleaf自动配置源码解析)