- 首先如果在SpringBoot项目中使用thymeleaf,必须在pom.xml文件中导入相应的依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
- thymeleaf是针对于HTML页面的如果想让thymeleaf语法在页面中正常的使用,就必须在提前告知该HTML页面是用了该语法。
<html lang="en" xmlns:th="http://www.thymeleaf.org"> 该句代码后面的xmlns:th="http://www.thymeleaf.org"就是告知页面使用thymeleaf
- 如果想把标签中的某个属性变成动态属性,在这个属性的后面再加一个th:xxx,xxx为动态属性的名称,然后在双引号中加入@或者$然后在大括号中加入要更改的内容。
<label style="color: red" th:text="${msg}">
thymeleaf零碎知识点
最新推荐文章于 2022-11-14 12:09:28 发布