我正在使用SimpleFormController,视图中有复选框。当表单提交时,复选框的值将正确地绑定到bean。但是,当表单(jsp视图)从onSubmit方法返回时,不会选中复选框。我试过做以下几件事:-
<input name="location" description="xyz" type="checkbox" id="location-filter-1" style="float:left" value="1"/><input name="location" description="xyz" type="checkbox" id="location-filter-1" style="float:left" value="1"/> <input type="hidden" name="_location" value="visible"/><springbind:bind path="location"> <input name="location" description="chennai" type="checkbox" id="location-filter-1" style="float:left" value="1"/> <input type="hidden" name="_location" value="visible"/> </springbind:bind>我在检查这些复选框方面没有运气。有人能为这件事提出建议吗。在bean中,使用一个整数数组来保存复选框的值:- private Integer[] location;
当前的复选框如下:-复选框按如下方式排列
<ul>
<li class="x">
<span>text</span>
<input type="checkbox" value="1" id="location-1" name="location"/>
</li>
<li><span>text</span>
<input type="checkbox" value="2" id="location-2" name="location"/>
</li>
<li>...</li>
..
</ul>发布于 2012-06-12 07:08:53
您应该尝试使用spring框架的表单标记库来绑定复选框的值。
<form:checkboxes items="" path=""/>在items属性中,传递保存复选框值的list,并在path中使用location。
希望这能帮到你。干杯。
https://stackoverflow.com/questions/10991772
复制相似问题