也许这个问题被问了很多,但不是以同样的方式,所以这里是我的问题,我希望有人可以帮助。提交复选框值Spring MVC
在已经获取从数据库中的一些研究行,返回的结果为List
我已经绑定到我的Spring MVC Controller
Model
:
if(!result.hasErrors())
{
try{
List<Question> questionlist = questionservice.findByCategoryAndLevel(questionform.getCategory(),questionform.getLevel());
model.addAttribute("questionlist",questionlist);
return "addExam";
}catch(NullPointerException e)
{
return "redirect:/admin/addexam";
}
}
这是我的观点:
<form:form action="addexam" method="POST" modelAttribute="questionlist">
<table class="table table-striped table-bordered table-hover" id="sample_1">
<thead>
<tr>
<th class="table-checkbox">
<input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/>
</th>
<th>
Category
</th>
<th>
level
</th>
<th>
Type of question
</th>
<th>
Status
</th>
<th>
</th>
</tr>
</thead>
<tbody>
<c:forEach items="${questionlist}" var="question">
<c:choose>
<c:when test="${question.isVisible()}">
<tr class="odd gradeX">
<td>
<input type="checkbox" class="checkboxes" />
</td>
<td>
${question.category.getCategoryName() }
</td>
<td>
${question.level }
</td>
<c:choose>
<c:when test="${question.isSingleChoiceQuestion() }">
<td>Question à choix unique</td>
</c:when>
<c:otherwise>
<td>Question à choix mutiple</td>
</c:otherwise>
</c:choose>
<td class="center">
<c:choose>
<c:when test="${question.getState() == 'Desactivated'}">
<span class="label label-sm label-default"> Desactivated </span>
</c:when>
<c:when test="${question.getState() == 'Activated'}">
<span class="label label-sm label-success"> Activated </span>
</c:when>
<c:when test="${question.getState() == 'Pending'}">
<span class="label label-sm label-warning"> Pending </span>
</c:when>
</c:choose>
</td>
<td>
<a href="${pageContext.request.contextPath }/admin/question?view=${question.idQuestion}" class="btn btn-xs btn-default" target="_blank">View</a>
</td>
</tr>
</c:when>
</c:choose>
</c:forEach>
</tbody>
</table>
</form:form>
现在如何提交所选项目?
你能否解释更多你的问题,whay你期待?你提交表格的目的是什么? 您还应该提供您控制器方法签名来检查绑定。 – tmarwen