【发布时间】:2016-05-06 12:07:03
【问题描述】:
我是 thymeleaf 和 spring boot 的新手,所以我真的不知道我在寻找什么来解决我的问题。 我的网站上的列表中显示了几个用户。当我点击其中一个用户时,我想显示用户个人资料页面。
列表如下所示:
<ul>
<li th:each="section : ${sections}">
<a href="overviewDivision.html?id=1" th:href="@{/overviewDivision?id=1}">
<span th:text="${section.name}">Bereich3</span>
</a>
<ul>
<li th:each="person : ${personSectionService.getPersonsBySectionId(section.id)}">
<a href="overviewEmployee.html?id= + person.id" th:href="@{/overviewEmployee?id= + person.id}">
<span th:text="${person.firstName + ' ' + person.lastName}">
</span>
</a>
</li>
</ul>
</li>
</ul>
这是我的控制器:
@RequestMapping(value = "/overviewEmployee", method = RequestMethod.GET)
public String overviewEmployee(Model model) {
model.addAttribute("sections", sectionService.getAllSections());
model.addAttribute("personSectionService", personSectionService);
model.addAttribute("currentPerson", personService.getById(1));
return "overviewEmployee";
}
在个人资料页面上,我使用 currentPerson.firstName 等来获取有关用户的信息。 所以我的问题是,如何将 currentPerson 更改为列表中最后点击的人?还是我做错了?
【问题讨论】:
标签: spring-boot thymeleaf user-profile