Spring Boot 使用Thymeleaf 3

74.9使用Thymeleaf 3

默认情况下,spring-boot-starter-thymeleaf使用Thymeleaf 2.1。如果您使用的是 spring-boot-starter-parent,您可以通过重写thymeleaf.versionthymeleaf-layout-dialect.version属性来使用Thymeleaf 3 ,例如:

<properties> 
    <thymeleaf.version> 3.0.2.RELEASE </thymeleaf.version> 
    <thymeleaf-layout- dialect.version>
 2.1.1 </thymeleaf-layout-dialect.version> </ properties>
[Note]

如果您自己在管理依赖关系,请查看spring-boot-dependencies与这两个版本相关的工件列表。

为了避免对被弃用的HTML 5模板模式和HTML模板模式的警告信息被用来代替,你可能还需要明确配置 spring.thymeleaf.modeHTML,例如:

spring.thymeleaf.mode:HTML

请参阅 Thymeleaf 3样本以查看这一行动。

如果您正在使用任何其他自动配置的Thymeleaf Extras(Spring安全性,数据属性或Java 8时间),您还应该将其每个版本覆盖为与Thymeleaf 3.0兼容的版本。

猜你喜欢

转载自blog.csdn.net/daqiang012/article/details/80234504