JSTL iterate over list of objects

前端 未结 2 1283
故里飘歌
故里飘歌 2020-12-03 00:50

I am getting a list \'myList\' of objects in jsp. Objects I am getting belongs to e.g \'MyClass\'. I want to iterate over this list through JSTL.

JSP code is below :

相关标签:
2条回答
  • 2020-12-03 01:42

    There is a mistake. See this line <c:forEach items="${myList}" var="element">. ${} around 'myList' was missing.

    <c:forEach items="${myList}" var="element"> 
      <tr>
        <td>${element.status}</td>
        <td>${element.requestType}</td>
        <td>${element.requestedFor}</td>
        <td>${element.timeSubmitted}</td>
      </tr>
    </c:forEach>
    
    0 讨论(0)
  • 2020-12-03 01:43

    replace it with

    `${element.status}`
    

    JSTL will look for standard getters setters on its own

    0 讨论(0)
提交回复
热议问题