Separate item in foreach tag (jstl)

前端 未结 2 922
猫巷女王i
猫巷女王i 2021-01-16 19:15

I have a JSP page with JSTL and I want to separate an user from other with an


tag. How can I solve it?



        
相关标签:
2条回答
  • 2021-01-16 20:07

    Put it inside the loop and use varStatus attribute of c:forEach to remove the one line you don't need in the end.

    <c:forEach var="user" items="${list_users}" varStatus="status">
      <c:out value="${user.name}" />
      <c:out value="${user.surname}" />
      <c:if test="${not status.last}">
        <hr />
      </c:if>
    </c:forEach>
    
    0 讨论(0)
  • 2021-01-16 20:13

    You can use a table to draw each user in the cell, then put <hr>

    <table>
    <c:forEach var="user" items="${list_users}">  
    <tr><td>  
     <c:out value="${user.name}"/><br>
     <c:out value="${user.surname}"/><br>
    <hr>
    </td></tr>
    </c:foreach>
    </table>
    
    0 讨论(0)
提交回复
热议问题