29.SpringBoot学习笔记–引入Thymeleaf
常见模板引擎
- JSP
- Velocity
- FreeMarker
- Thymeleaf
模板引擎原理图
Thymeleaf
引入 Thymeleaf
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
参考 spring-boot-dependencies
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
<thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-data-attribute.version>
<thymeleaf-extras-java8time.version>3.0.4.RELEASE</thymeleaf-extras-java8time.version>
<thymeleaf-extras-springsecurity.version>3.0.4.RELEASE</thymeleaf-extras-springsecurity.version>
<thymeleaf-layout-dialect.version>2.4.1</thymeleaf-layout-dialect.version>
Thymeleaf 相关的依赖版本均为当前最新,如果需要自定义版本,可以参考以下配置:
<properties>
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
<!-- 布局功能的支持程序 -->
<!-- 要选择与配置的thymeleaf适配的版本 -->
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
</properties>
Thymeleaf 的官网:
Thymeleaf 的代码仓库:
thymeleaf-layout-dialect 的代码仓库: