【发布时间】:2016-06-26 20:56:43
【问题描述】:
在 GET 方法中,我将这些添加到模型中:
model.addAttribute("team", team);
model.addAttribute("players", team.getPlayers());
model.addAttribute("inviting", new InvitingPlayerToTeam());
还有这个模型的视图片段:
<div id="news" th:fragment="playerList">
<span>Nazwa: </span>
<span th:text="${team.name}">nazwa teamu</span>
<br>
<span th:each="player : ${players}" th:utext="${player.username} + '</br>'">-</span>
<br><br>
<form method="POST" th:action="@{/team/invitePlayer}" th:object="${inviting}">
Nazwa <input type="text" th:field="*{username}">
<input type="hidden" th:field="*{teamId}" th:value="${team.id}">
<br>
<input type="submit" value="Zaproś">
</form>
</div>
怎么了?在 post 方法字段中 inviting.username 具有良好的价值,但 inviting.teamId 是 0。问题出在哪里?
【问题讨论】: