2

I have this little issue that is cracking my skull :( I have a 2D Array in my class, I send it by request to my jsp page and I have to iterate through it BUT by columns! I know I can do

    <c:forEach items="${board.cells}" var="row">
     <tr>
       <c:forEach items="${row}" var="cell">
        <td><c:out value="${cell}"/></td>
       </c:forEach>
     </tr>
    </c:forEach>

And iterate by rows, but I can't find a way I can do that but by columns. I hope you guys understand what I'm trying to do and can help me. Greetins from Colombia and thank you!

ManoPajaro
  • 65
  • 1
  • 9

1 Answers1

0

you can pass from controller only the array for exemple:

addModu..("board",array[][]); // exemple pass only array

now you can try this :

  <c:forEach items="${board}" var="row">
     <tr>
       <c:forEach items="${row}" var="cell">
        <td><c:out value="${cell}"/></td>
       </c:forEach>
     </tr>
    </c:forEach>

as you already you're passing the array, forEach iterate for each position on array

I think your problem is how to pass the parameter...

Good Lucky

Kappys
  • 673
  • 2
  • 7
  • 20
  • I made a workaround by sending a single array with every column as an array in each position, so it "looks" like a 2D array but it's way easier to iterate over it. Not the best solution but it worked for me. Thanks :) – ManoPajaro Apr 29 '14 at 16:40
  • vale manoPajaro jajaja en español te lo podria haber explicado mejor xD – Kappys Apr 29 '14 at 20:06