JSTL 实现 为Select赋多个值

需要注意需要在.jsp文件中引入相应的类库
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<select id="rights" name="rights" multiple="multiple"> <c:forEach items="${tqListAll}" var="tq"> <c:set var="isContains" value="${fn:contains(tqListSelected,tq.id)}" /> <c:choose> <c:when test="${isContains}"> <option value=${tq.id} selected="selected">${tq.name}</option> </c:when> <c:otherwise> <option value=${tq.id}>${tq.name}</option> </c:otherwise> </c:choose> </c:forEach> </select>
posted @ 2017-10-24 08:04  梦见舟  阅读(924)  评论(0编辑  收藏  举报