How to skip the first element of a list in c: forEach
2 answers
Use varStatus
in the test forEach
andif
<c:forEach items="${list}" var="item" varStatus="state">
<c:if test="${not state.first}">
${item}
</c:if>
</c:forEach>
Other useful properties of varStatus :
-
current
Item (from collection) for the current round of iteration -
index
Zero-indexed index for the current round of iteration -
count
A unit counter for the current round of iteration -
first
Flag indicating whether the current round is the first pass through the iteration -
last
Flag indicating whether the current round is the last pass through the iteration -
begin
Begin attribute value -
end
End attribute value -
step
The value of the step attribute
+5
source to share