Iterating over ArrayList items with JSTL forEach

后端 未结 2 1894
余生分开走
余生分开走 2021-01-20 12:22

I\'m having problem running over ArrayList items and displaying them in JSP file.

Here is my bean:

public class UsersList {
    private ArrayList<         


        
相关标签:
2条回答
  • 2021-01-20 12:45

    Since your adding the object to session you need to access it from sessionScope in EL.

    <c:forEach var="current" items="${sessionScope.bean.users}" >
    <tr>
        <td>${current.email}</td>
        <td>${current.username}</td>
        <td><input type="checkbox" name="delete" value="${current.email}"</td>
    </tr>
     </c:forEach>
    
    0 讨论(0)
  • 2021-01-20 13:05

    Check if your prefix "c" points to the right tag library.

    It should be

    "http://java.sun.com/jsp/jstl/core"

    If that does not work, check if there is mistake in the logic of populating the data.

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