【发布时间】:2018-02-01 03:38:28
【问题描述】:
我有一个由forEach 弹簧标签显示的对象列表。这是jsp的代码:
<c:forEach items="${liste_fiche}" var="fiche">
<div class="card blue-grey darken-1">
<form:form action="display_fiche" method="post" commandName="fiche" varStatus="status">
<div class="card-content white-text">
<span class="card-title">Fiche numéro ${fiche.id}</span>
<p>reference de la fiche : ${fiche.ref_fiche}</p>
<p>type de fiche : ${fiche.typeFiche}</p>
</div>
<div class="card-action">
<button type="submit" action="display_fiche"
class="waves-effect waves-light btn">Afficher la fiche</button>
</div>
</form:form>
</div>
</c:forEach>
当我点击“Afficher la fiche”时,我想在另一个控制器上选择实际的 fiche 对象。
我尝试通过以下控制器进行操作:
@RequestMapping(value="display_fiche", method = RequestMethod.POST)
private ModelAndView displayFiche(@ModelAttribute("fiche") Fiche fiche, ModelMap modelMap) {
System.out.println("Fiche séléctionnée : " + fiche.getId());
return model;
}
我不知道这是否是好方法,因为它不起作用。我总是得到一个“0”到fiche.getId()。如果不可能,我怎么能只传递fiche.id 元素?
【问题讨论】:
标签: spring jsp spring-mvc spring-annotations