【发布时间】:2018-11-21 17:57:59
【问题描述】:
我有一个带有 href 的值表。
<tr th:each="note : ${test}">
<td th:text="${note.name}"><a href="@{/}"></a>></td>
<td th:text="${note.lastName}"></td>
<td th:text="${note.studentId}"></td>
<td>
<a th:href="@{'/seeStudent/' + ${note.studentId}}">Ver</a>
</td>
</tr>
这是我的控制器:
@GetMapping("/seeStudent/{id}")
public String getStudentById(@PathVariable Long id, Model model) {
model.addAttribute("student", repo.findById(id));
return "seeStudent";
}
这是我的 HTML:
<div>
<h1>Student information</h1>
<ul>
<div th:object="${student}">
<li>
<h4>
<span th:text="${name}"></span>
</h4>
<h4>
<span th:text="${lastName}"></span>
</h4>
</li>
</div>
</ul>
</div>
由于某种原因,显示屏出现空白,就好像它没有通过 ID 找到学生一样。当我调试它确实找到学生并返回它。我相信在尝试提取对象数据并将其显示在我的 html 中时我可能做错了什么。有什么想法吗?
【问题讨论】:
标签: html spring spring-mvc thymeleaf