spring_boot_all_study/SpringBootThymeleaf/target/classes/templates/demo1.html

41 lines
899 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>demo1</title>
</head>
<body>
<h1>${...} : 变量表达式。 演示</h1>
<h3>1 取值,直接显示</h3>
<span >你好</span>
<span th:text="${helloname}"></span>
<h3>2 对象,显示</h3>
<span th:text="${a.name}"></span>
<h3>3 List显示</h3>
遍历迭代的语法th:each="自定义的元素变量名称 : ${集合变量名称}"
状态变量的使用语法th:each="自定义的元素变量名称, 自定义的状态变量名称 : ${集合变量名称}"
不管什么时候Thymeleaf 始终会为每个th:each创建一个状态变量
默认的状态变量名称就是自定义的元素变量名称后面加Stat字符串组成
<table border="1">
<tr>
<th>名字</th>
<th>电话</th>
</tr>
<tr th:each="c:${cs}">
<td th:text="${c.name}"></td>
<td th:text="${c.tel}"></td>
</tr>
</table>
</body>
</html>