I am trying to iterate through a list of 8 specific items. I would need to show the first three, but it has not been very clear to me how to do it.
I appreciate the help.
<c:forEach begin="0" step="1" end="3" items="${Articulos}">
<div>${item.idArticulo}</div>
<a class="destacado my-2" style="word-break: break-word;"
href="${item.url}">${item.nombre}</a>
</c:forEach>
I know it's not right but at least it serves to explain my doubt.
In the list of articles, I have 8 articles, I want it to show me only 3 articles.
You're using
item
as a variable to refer to the item in each iteration, but you haven't declared it, I think that's the only thing you're missing:A detail: the index starts at 0 and
end
indicates the limit inclusively, so to show the first three elements you need to set it to 2, not 3