Thymeleaf简介
Thymeleaf是一种Java模板引擎。
Thymeleaf能够处理HTML,XML,JavaScript,CSS以及纯文本,类似于freemarker。语法优雅易懂、遵从web标准。
Thymeleaf的主要目标是提供一个优雅和高度可维护的创建模板的方式。 为了实现这一点,它建立在自然模板的概念之上,以不影响模板作为设计原型的方式将其逻辑注入到模板文件中。 这改善了设计沟通,弥合了前端设计和开发人员之间的理解偏差。即我们所说的前后端分离。
Thymeleaf使用
1,我们创建一个Spring Boot项目,然后pom文件添加相关jar包。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>