有一个属性设置列表here - 您可以在该页面上搜索“thymeleaf”以找到相关部分。
例子:
Key Default Value Description
spring.thymeleaf.prefix classpath:/templates/ Prefix that gets prepended to view names when building a URL.
此示例显示,对于 Thymeleaf ClassLoaderTemplateResolver,使用默认值 /templates/(如您所述)。
我不知道它是否是权威的完整列表 - 但它看起来相当全面,基于我通常期望在非 Spring Thymeleaf 实现中设置的设置。
更新
要添加更多细节,请查看文档中的两个示例:
示例 1: spring.thymeleaf.cache - 默认为 true
对于这个值,默认在AbstractConfigurableTemplateResolver类中定义:
public static final boolean DEFAULT_CACHEABLE = true;
这是source code on GitHub的链接。
示例 2: spring.thymeleaf.prefix - 默认为 classpath:/templates/
在这种情况下,有一个 Spring 类可以处理这个(以及许多其他)默认值:org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties
跳到straight to the source 并查看那里设置的默认值可能是最简单的。
例如prefix example:
public static final String DEFAULT_PREFIX = "classpath:/templates/";
还值得注意的是,上面示例 1 中的 cache 设置也在 Spring ThymeleafProperties 类中显式设置。
附加说明
还有一些用于响应式设置的属性:
spring.thymeleaf.reactive.max-chunk-size - 默认为0B
这是在嵌套的Reactive 类中设置的:
private DataSize maxChunkSize = DataSize.ofBytes(0);
以上位置仍不是 100% 全面。例如:
spring.thymeleaf.enable-spring-el-compiler 根据文档设置为false。而且在源代码中它是隐含的错误:
private boolean enableSpringElCompiler;
但这并不能告诉您可能的编译器设置是什么,如果您选择将此属性设置为true(请参阅here)。
关于属性文件的说明
我不知道有任何默认属性文件或属性文件模板用作此 Thymeleaf 配置过程的一部分。我的理解是,如果你想自定义这些设置,而你还没有 Spring 属性文件,你必须自己创建它——但我可能弄错了。
附加说明 2
以DEFAULT_PREFIX 为例:这是由ThymeleafAutoConfiguration 类(here)处理的。这会在 SpringResourceTemplateResolver 类中设置前缀,该类是 Thymeleaf 的 Spring 集成模块的一部分(来源 here)。
resolver.setPrefix(this.properties.getPrefix());
这个解析器“使用 Spring 的资源解析机制解析模板”——这是我的研究停滞不前的地方。
关于默认前缀和spring.thymeleaf.prefix提供的值之间的关系,我看到直接连接的唯一位置是here,它调用PropertyResolver方法返回用户提供的属性值,或者否则为默认值,否则。但同样,这只是为了验证模板是否可以被定位(而不是实际被检索)——所以这肯定不是全部情况。同样,这是我的研究停滞不前的地方。