2014-09-03 125 views
0

我有圖像的一個數組列表,列表,以針對特定的圖像:嘗試在JSP foreach循環

<c:forEach items="${articleContent.articleMediaList}" var="gridImage" varStatus="imgCount"> 
    <img src="${imagePath}${gridImage.image"/> 
</c:forEach> 

眼下,這是打印出的所有圖像。我只是想讓它打印出第三張圖片。另外,我怎樣才能打印出一系列圖像,比如1到3?

+0

使用[varStatus](http://docs.oracle.com/javaee/6/api/javax/servlet/jsp/jstl/core/LoopTagStatus.html) 獲取索引[c:forEach varStatus屬性] (http://www.bmchild.com/2012/03/jstl-cforeach-varstatus-properties.html)。 – 2014-09-03 17:27:33

+0

我將如何能夠在每第三張圖片上進行操作? – 2014-09-03 18:22:25

回答

1

您可以使用imgCount.count或imgCount.index獲取編號,然後您可以處理它。