【发布时间】:2016-03-26 02:15:48
【问题描述】:
我是 thymeleaf 和 Spring 的新手——我正在为我的学校班级做一些小项目,但我的 html 链接有问题。我现在遇到了 2 个小时的麻烦,我用 10 种不同的方式编辑我的代码,所以请回答如何正确地做到这一点。下面是我的 html 模板(我在这里尝试使用 th:href 有两种不同的方式:
<table>
<th>Name</th>
<th>Date</th>
<th>See</th>
<th>Edit</th>
<a th:each=" i : ${workouts}" varStatus="status">
<tr>
<td><a th:text="${i.getName()}"/></td>
<td><a th:text="${i.getDate()}"/></td>
<td><a href="seeWorktoutPage.html" th:href="@{'/seeWorkoutPage/'${i.getId()}}">See</a></td>
<td><a href="seeWorktoutPage.html" th:href="@{seeWorkoutPage(id=${i.getId()})}">See</a></td> </tr>
</a>
</table>
这是我的控制器: @控制器 公共类 SeeWorkoutController {
@RequestMapping(value = "/seeWorkoutPage/{id}", method=RequestMethod.GET, params="id")
public String test2(@PathVariable("id")Long id, Model model) {
System.out.println(id);
return "workoutsPage";
}
但它现在可以正常工作。请帮忙。
【问题讨论】:
标签: java html spring spring-mvc thymeleaf