【发布时间】:2015-10-15 15:07:52
【问题描述】:
我有一个带有函数列表的 jsp 页面。在控制器中,我从数据库中获取此列表并将其传递给 jsp。
@RequestMapping(value = "/functionlist", method = RequestMethod.GET)
public ModelAndView functionList(Model model) throws Exception {
ModelAndView mv = new ModelAndView("functionList");
mv.addObject("functionList", getFunctionsFromDB());
return mv;
}
在我的 jsp 页面中,我使用此函数列表创建表
<table id="table">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:choose>
<c:when test="${not empty functionList}">
<c:forEach var="function" items="${functionList}">
<tr>
<td><input name="id" value="${function.id}" hidden></td>
<td>${function.name}</td>
<td>
<input type="checkbox" id="${function.id}" value="${function.action}"></td>
</tr>
</c:forEach>
</c:when>
</c:choose>
</tbody>
</table>
<button type="submit" name="save">Save</button>
我还将函数 id 赋予复选框 id。
我的 Function 实体如下
public class Function {
private Integer id;
private String name;
private Boolean action;
...
}
我想按下按钮保存并进入控制器“/functionlist/save”我的复选框值列表。
【问题讨论】:
标签: spring jsp spring-mvc checkbox