Reputation: 77
How do I add logic to do for loop only if ${link[i].alt}
is not empty?
How to add index to the jsp var ...like ${link${i}.credit}
??
<c:forEach var="i" begin="1" end="6">
<li>${i}
<a class="lnid-sec1_lnk${i}" href="${link.href}">
<div class="l-wrapper">
<img data-src="${link1.credit}" src="${link1.credit}" alt="${link1.alt}" width="100">
<div class="team-name">
<span>${link1.alt}</span>
</div>
</div>
</a>
</li>
</c:forEach>
Upvotes: 1
Views: 1144
Reputation: 899
For not empty you can use this
<c:if test="${!empty link[i].alt}"></c:if>
Upvotes: 0
Reputation: 802
Ans:1
<c:if test="${!empty link[i].alt}"></c:if>
Ans: 2
<c:set var="your_var" value="${link[i.index].credit}"/>
Upvotes: 1
Reputation: 332
add varStatus
so
<c:forEach var="i" begin="1" end="6" varStatus="yourIndex">
Then
(${yourIndex.index}) contains the index
Upvotes: 1