【发布时间】:2014-06-29 10:37:34
【问题描述】:
我有一个模型:
public class Header {
private Boolean SERVICE;
}
控制器:
@RequestMapping("mymodel/Edit")
public ModelAndView mymodelEdit(
@ModelAttribute("mymodel") Mymodel mymodel,
@RequestParam String id) {
Mymodel old_mymodel = mymodelService.getMymodel(id);
Map<String, Object> map = new HashMap<String, Object>();
map.put("old_mymodel", old_mymodel);
return new ModelAndView("mymodel/mymodelEditView", "map", map);
}
JSP 表单
<c:set var="old_mymodel" value="${map.old_mymodel}" />
<form:form method="POST action="/mymodel/Save" modelAttribute="mymodel">
<tr>
<td>Сервис :</td>
<td>
<form:checkbox path="SERVICE" value="${old_mymodel.SERVICE}">
</form:checkbox>
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Save" /></td>
</tr>
</table>
</form:form>
我的问题:我无法将 db 中的值设置为表单值,即当 SERVICE 值为 true 时,未选中复选框。
【问题讨论】:
标签: java jsp spring-mvc