⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 foreach.jsp

📁 用jsp语言自己做的一个网站bookshot的全套程序以及一些样例。完全属于原创。
💻 JSP
字号:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>

<html>
  <head>
    <title>All Employees</title>
  </head>
  <body bgcolor="white">

    <%-- Set number of rows to process --%>
    <c:set var="noOfRows" value="2" />

    <c:if test="${empList == null}">
      <sql:query var="empList" scope="session"
        sql="SELECT * FROM Employee ORDER BY LastName" 
      />
    </c:if>

    <c:choose>
      <c:when test="${empList.rowCount == 0}">
        No one seems to work here anymore ...
      </c:when>
      <c:otherwise>
        The following people work here:
        <p>
        <table border="1">
          <th>Last Name</th>
          <th>First Name</th>
          <th>Department</th>
          <th>Email Address</th>
          <c:forEach items="${empList.rows}" var="row" 
            begin="${param.start}" end="${param.start + noOfRows - 1}">
            <tr>
              <td><c:out value="${row.LastName}" /></td>
              <td><c:out value="${row.FirstName}" /></td>
              <td><c:out value="${row.Dept}" /></td>
              <td><c:out value="${row.EmailAddr}" /></td>
            </tr>
          </c:forEach>
        </table>
      </c:otherwise>
    </c:choose>
    <p>
    <c:choose>
      <c:when test="${param.start > 0}">
        <a href="foreach.jsp?start=<c:out 
          value="${param.start - noOfRows}" />">
          Previous Page</a>
      </c:when>
      <c:otherwise>
          Previous Page
      </c:otherwise>
    </c:choose>
    <c:choose>
      <c:when test="${param.start + noOfRows < empList.rowCount}">
        <a href="foreach.jsp?start=<c:out 
          value="${param.start + noOfRows}" />">
          Next Page</a>
      </c:when>
      <c:otherwise>
          Next Page
      </c:otherwise>
    </c:choose>
  </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -