使用c:forEach设置复选框值
courseware.downloadType 值为"01,02,03"
<c:if test="${courseware.downloadType ne null and courseware.downloadType ne ''}">
<c:forEach var="downloadType" items="${courseware.downloadType}" varStatus="status">
<c:if test="${downloadType eq '01'}"><c:set var="check01" value="checked='checked'" scope="page"/></c:if>
<c:if test="${downloadType eq '02'}"><c:set var="check02" value="checked='checked'" scope="page"></c:if>
<c:if test="${downloadType eq '03'}"><c:set var="check03" value="checked='checked'" scope="page"></c:if>
</c:forEach>
<input type="checkbox" name="downloadType" ${check01} value="01" />视频
<input type="checkbox" name="downloadType" ${check02} value="02" />音频
<input type="checkbox" name="downloadType" ${check03} value="03" />讲义
</c:if>
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 陈大雷的 Blog