JSTL select和checkbox的用法

时间:2021-12-19 18:05:02

select的 用法

<select id="roleIds" name="roleIds" multiple="true" background:#000000  value="${roleIds}"  style="width:150px" cssClass="SelectStyle" >
<c:forEach items="${roleList}" var="c" varStatus="status">
<option value="${c.id}" <c:forEach items="${roleIds}" varStatus="va"> <c:if test="${roleIds[va.index]==c.id}">selected</c:if></c:forEach> > ${c.name}</option>
</c:forEach>
</select>

checkbox的用法a

<c:forEach items="${privilegeList}" var="p">
<input type = "checkbox" name="privilegeIds" value="${p.id}"
  <c:forEach items="${privilegeIds}" varStatus="va"><c:if test="${privilegeIds[va.index]==p.id}">checked</c:if></c:forEach>
    >${p.name }</input>
</c:forEach>