JSTL select和checkbox的用法

select的 用法

<select id="roleIds" name="roleIds" multiple="true" background:#000000  value="${roleIds}"  style="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>
原文地址:https://www.cnblogs.com/wujixing/p/5680751.html