复选框回显操作

在对有选择复选框的页面进行修改的时候  要把修改前原数据回显过来,可以这样做 、如下:
主要是运用到了双循环进行 
连个foreach循环中的item 都是在控制器中写好的。
其中第一个循环 表示的是所有的项  ,第二个循环 表示的是修改前选中的项

<tr>
    <td width="120px">
        <label for="payment">支付类型:</label>
    </td>
    <td class="tdspace"></td>
    <td colspan="4">
        <c:forEach items="${payTypeList}" var="payType">
            <input type="checkbox" name="payment" id="payment"
                   value="${payType.code }"
            <c:forEach items="${paymentListChecked}" var="paymentChecked">
                <c:if test="${payType.code == paymentChecked }">
                    checked
                </c:if>
            </c:forEach>
            />
            ${payType.name }
        </c:forEach>
    </td>
</tr>
原文地址:https://www.cnblogs.com/xuerong/p/5534241.html