41 lines
899 B
HTML
41 lines
899 B
HTML
|
<!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>
|