71.10 使用Thymeleaf 3

默认情况下,spring-boot-starter-thymeleaf使用的是Thymeleaf 2.1,你可以通过覆盖thymeleaf.versionthymeleaf-layout-dialect.version属性使用Thymeleaf 3,例如:

<properties>
    <thymeleaf.version>3.0.0.RELEASE</thymeleaf.version>
    <thymeleaf-layout-dialect.version>2.0.0</thymeleaf-layout-dialect.version>
</dependency>

为了避免关于HTML 5模板模式过期,将使用HTML模板模式的警告提醒,你需要显式配置spring.thymeleaf.modeHTML,例如:

spring.thymeleaf.mode: HTML

具体操作可查看Thymeleaf 3示例

如果正在使用其他自动配置的Thymeleaf附加组件(Spring Security,Data Attribute或Java 8 Time),你需要使用兼容Thymeleaf 3.0的版本覆盖它们现在的版本。

Last updated