how to Use in scripts tag on JSP page?

后端 未结 1 1947
挽巷
挽巷 2020-12-18 21:37

Hey How to use loop in tag in jsp page?

i want to use JSTL data to pass in data tables

my code is like :

        $(document).ready         


        
相关标签:
1条回答
  • 2020-12-18 22:20
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <html>
    <head>
    <title><c:forEach>YOUR CODE </title>
    </head>
    <body>
    <c:forEach var="i" begin="1" end="5">
       NAME <c:out value="${i}"/><p>
    </c:forEach>
    </body>
    </html>
    

    This would produce following result:

    NAME 1
    NAME 2
    NAME 3
    NAME 4
    NAME 5
    

    Above is simplest example.. following is with items var

    <table>
          <c:forEach var="student" items="${person.person}" varStatus="counter">
            <c:choose>
              <c:when test="${counter.count % 2 == 0}">
                <c:set var="rowStyle" scope="page" value="odd"/>
              </c:when>
              <c:otherwise>
                <c:set var="rowStyle" scope="page" value="even"/>
              </c:otherwise>
            </c:choose>
            <tr class="ÃÂ${rowStyle}">
              <td>${student.name}</td>
              <td>${student.age}</td>
              <td>${student.height}</td>
            </tr>
          </c:forEach>
        </table>
    

    this way you can use the <c:forEach> </c:forEach> TAG..

    If you have any specific problem then please explain

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