一、介绍
Thymeleaf是Spring boot推荐使用的模版引擎,直接以html显示,前后端可以很好的分离。
二、依赖与约束
依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.5.5</version>
</dependency>
约束
<html lang="en" xmlns:th="http://www.thymeleaf.org">
三、语法
只是一些常用语法,一些不经常使用的没有列出!!!
1、<div th:text="${}"></div> //文本替换
2、<div th:utext="${}"></div> //支持html的文本替换
3、<input th:value="${}"></input> //赋值(注意与text的区别)
4、<div th:each="msg:${msglist}">
<span th:text="${msg.id}"></span>
<spa