这是我的JSP页面。首次添加值时需要获取值,以便可以用新值更新
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="modules">Modules:</label>
</div>
<div>
<c:forEach items="${module}" var="mr">
<input id="option" type="checkbox" name="moduleIds"
value="${mr.id}">
<label for="option"> <c:if test="${mr.id eq
m}">checked='checked'</c:if>${mr.moduleName}</label>
<br>
</c:forEach>
</div>
</div>
控制器:
@RequestMapping(value = "/course_edit", method = RequestMethod.GET)
public ModelAndView updateCourseForm(Model model, @RequestParam int id) {
Course course = new Course();
ModelAndView form = new ModelAndView("/Admin/updateCourse");
model.addAttribute("module", modulesService.allmodules());
form.addObject("course", courseService.getCourseById(id));
form.addObject("m", course.getModules());
return form;
}