1

Is there any possibility to get only the first element from list in view?

 <c:forEach items="${products}" var="product">
     <h3>${product.name}</h3>
 </c:forEach>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Jack937
  • 33
  • 1
  • 8

1 Answers1

2

When you're sure there is at least one element, you could write:

<c:set var="first" value="${products[0]}"/>
Ali Dehghani
  • 46,221
  • 15
  • 164
  • 151