jstl <c:forEach> 遍历,多个<option>时显示"全部"。单个
option时,默认选中!
引入:<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<select id="company" name="company" > <c:if test="${not empty companies}"> <c:if test="${fn:length(companies)>1}"><option value="">全部</option></c:if> <c:forEach var="company" items="${companies}" varStatus="status"> <option value="${company.COMPANY_ID}" <c:if test="${param.company eq company.COMPANY_ID}">selected</c:if>> ${company.COMPANY_ID}-${company.COMPANY_NAME} </option> </c:forEach> </c:if> </select>