带foreach的java Spring MVC表单
我有一个关于Spring的问题,特别是MVC组件。我有一个jsp页面,其中包含以下代码
<form:form modelAttribute="sentenceModelAttribute"
method="POST" action="sentencemanagement.htm">
<table class="activity">
<tr>
<th/>
<th>ID</th>
<th>Description</th>
<th>Action</th>
<th>Decision</th>
</tr>
<c:forEach items = "${model.allSentences}" var="sentence">
<tr>
<td><form:radiobutton path="id" value="${sentence.id}"/></td>
<td>${sentence.id}</td>
<td>${sentence.description}</td>
<td>${sentence.action}</td>
<td>${sentence.decision}</td>
</tr>
</c:forEach>
</table>
<input type="submit" name="modify" value="Modify"/>
<input type="submit" name="cancel" value="Cancel"/>
</form:form>
POST连接到控制器中的一个方法,该方法有一个参数sentenceModelAttribute。当前,此参数具有所选radiobutton中对象的所有值。这确实是我想要的。 我的问题是它是如何做到的?它如何将我从表中选择的对象与modelAttribute中显示的对象联系起来
共 (0) 个答案