【发布时间】:2017-09-02 03:06:19
【问题描述】:
我想用 Spring MVC 在浏览器中显示数据库中的数据。一切都很好,除了每个循环的 Thymeleaf 模板。那里出了点问题。
如何在 ID 行中显示 id 数据,在 Name 行中显示 name 数据,并使用 for each 遍历对象集合em> 循环?
源代码:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<table border="1">
<tr style="font-size: 13">
<td>ID</td>
<td>Name</td>
</tr>
<tr th:each="count : ${id}">
<td><p th:text="${count}" /></td>
<td><p th:text="${name}" /></td>
</tr>
</table>
</body>
</html>
【问题讨论】:
标签: java spring-mvc thymeleaf