2 linguoqing0809 linguoqing0809 于 2015.07.05 00:18 提问

在<c:forEach ></c:forEach>中如何定义数组变量,请jstl高手指导

/c:forEach中如何定义数组变量,请jstl高手指导

1个回答

guwei4037
guwei4037   Ds   Rxr 2015.07.05 07:19
 <%
    String[] colors = new String[] { "red", "green", "yellow", "black","silver" };
    pageContext.setAttribute("colors", colors);
%>

<c:forEach var="color" items="${pageScope.colors}">
    <c:if test="${color=='yellow'}">
        <c:out value="${color}" />
    </c:if>
</c:forEach>

http://blog.csdn.net/chinacsharper/article/details/39855287

Csdn user default icon
上传中...
上传图片
插入图片