Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to iterate an ArrayList of object array using JSTL?

Tags:

jsp

jstl

I have a list of object array like this.

List<Object[]> reqUserDetails = new ArrayList<Object[]>();

Now I have to iterate this list and take values like Object[0],Object[1].... How can I do this using JSTL?

like image 579
Usr1123 Avatar asked Feb 02 '15 06:02

Usr1123


1 Answers

The general syntax is to itearate it like ,

<c:forEach items="${outerList}" var="innerList">
  <c:forEach items="${innerList}" var="item">
     // Print your object here
  </c:forEach>
</c:forEach>

and in your case ,

<c:forEach items="${reqUserDetails}" var="firstVar"> 
      <c:forEach items="${firstVar}" var="secodVar"> // firstVar will hold your object array
         <c:out value="${secondVar.field1}" /> // on iterating the object array 
      </c:forEach>
  </c:forEach>

as it contains array of objects inside the List . so the outerList will hold the Object[] which you need to iterate again.

Hope this helps !!

like image 124
Santhosh Avatar answered Oct 11 '22 10:10

Santhosh