开发者

JSTL iterate over list of objects

开发者 https://www.devze.com 2023-03-02 18:41 出处:网络
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.

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 :

<c:forEach items="myList" var="element">    
  <tr>
    <td>${element.getStatus()}</td>
    <td>${element.getRequestType()}</td>
    <td>${element.getRequestedFor()}</td>
    <td>${element.getTimeSubmitted()}</td>
  </tr>
</c:forEach>

I am getting exception :

 00000024 WebApp  E   [Servlet Error]-[/requestHistory.jsp]: com.ibm.ws.jsp.translator.JspTranslationException: JSPG0227E: Exception caught while translating /requestHistory.jsp:  
    /requestHistory.jsp(31,6) --> JSPG0122E: Unable to parse EL function ${UserProcessR开发者_开发问答equests.getStatus()}.

Taglib I am using are :

 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 <%@ page isELIgnored="false"%>


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>


replace it with

`${element.status}`

JSTL will look for standard getters setters on its own

0

精彩评论

暂无评论...
验证码 换一张
取 消