<c:otherwise> <c:set var="flag" value="true" /><!-- 设置flag --> <c:forEach items="${roleDepartList}" var="roleDepart" varStatus="status"> <c:set var="isEqual" value="false"></c:set><!--假如外层循环的内层循环中没有找到相等的,则标记不相等,并且把不相等的显示出来--> <c:if test="${(status.index+1) % cols == 1}"><tr></c:if><!--每cols列之后就换行--> <c:forEach items="${selectedRoleIdList}" var="selectedRole" varStatus="roleIndex"> <c:if test="${selectedRole.roleId == roleDepart.roleId}"> <td><input type="checkbox" id="roleId${status.index+1}" checked name="roleId" title="${roleDepart.roleName }" value="${roleDepart.roleId }"></td> <c:set var="isEqual" value="true"></c:set><!--假如外层循环的内层找到相等的,则显示相等的,并跳出当前循环,继续外层循环--> <c:set var="flag" value="false"/><!--为false则跳出当前循环,继续外层循环 --> </c:if> </c:forEach> <c:if test="${isEqual=='false' }"> <td><input type="checkbox" id="roleId${status.index+1}" name="roleId" title="${roleDepart.roleName }" value="${roleDepart.roleId }"></td> </c:if> <c:if test="${(status.index+1) % cols == 0}"></tr></c:if> </c:forEach> </c:otherwise>