Skip to content

Instantly share code, notes, and snippets.

@devheedoo
Created September 23, 2016 04:51
Show Gist options
  • Save devheedoo/131e25ae31094be536634bf3db6d52b6 to your computer and use it in GitHub Desktop.
Save devheedoo/131e25ae31094be536634bf3db6d52b6 to your computer and use it in GitHub Desktop.
Pratice JSTL c tag - forEach
<c:forEach items="${list}" var="item" varStatus="stat">
<!-- varStatus has index attribute that counts automatically -->
<c:if test="${stat.index == 0}">the first item</c:if>
<a href="${item.link}" <c:if test="${(item.prop1 == 'A') || (empty item.prop1)}"> attr1="val1" </c:if>>
<!-- src can use the value -->
<img src="/file/${item.prop2}" alt="${item.prop3}" />
</a>
</c:forEach>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment