form:checkboxes数据回显问题

xiaoxiao2021-03-01  18

<form:checkboxes items="${list}" path="${path}" />

items要求为集合,是所有选择框的选项

path也要求为集合,是所有已选择框的选项

checkboxes 得到的数据是集合,数据库保存的是字符串,所以需要手动转

 

例:

修改表单用这个,z为集合类型,如果是字符串类型,则只有一个选项打钩

<c:if test = "${not empty first.d}"> <form:checkboxes path="z" items="${fns:getDictList('d')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/> </c:if>

新增表单用这个,d为String类型,如果是集合类型,则直接报错 <c:if test = "${empty first.d}"> <form:checkboxes path="d" items="${fns:getDictList('d')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/> </c:if>

 

转载请注明原文地址: https://www.6miu.com/read-4050008.html

最新回复(0)