jsp前端實現分頁代碼

來源:互聯網
上載者:User

標籤:count   接受   glib   jsp頁面   prefix   charset   頁面   add   ota   

前端需要訂一page類封裝,其參數為

private Integer pageSize=10; //每頁記錄條數=10

private Integer totalCount; //總記錄條數

private Integer totalPage; //總頁數

private Integer currPage; //當前頁

private Integer startIndex; //開始索引

private List<M> list; //結果集

進行查詢的資料set進對象,在運用ModelAndView對象

ModelAndView .addObject("page",page);

將page返回前台jsp,接受成功之後在其他頁面直接引用jsp標籤<jsp:include page="/page.jsp" />就可以調用

以下為jsp頁面代碼:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><!-- 最下面顯示跳轉頁面 --><!-- ${page.totalCount }總的記錄條數  其他的類似,與Page.java相關聯 --><div >共 <i class="blue">${page.totalCount }</i> 條記錄,當前顯示第 <i class="blue">${page.currPage }</i> 頁 / 共 <i class="blue">${page.totalPage }</i> 頁    跳轉  <input type="text" class="scinput" style="width: 40px;height: 20px" id="currPage2" onblur="page2()" onkeyup="this.value=this.value.replace(/\D/g,‘‘)"onafterpaste="this.value=this.value.replace(/\D/g,‘‘)" />  頁     <!-- 首頁按鈕,跳轉到首頁 -->    <p>  <c:if test="${page.currPage <= 1 }"></c:if>     <a href="javascript:;" <c:if test="${page.currPage > 1 }">onclick="page1(1)"</c:if> >首頁</a>            <!-- 上頁按鈕,跳轉到上一頁 -->    <c:if test="${page.currPage <= 1 }"></c:if>     <a href="javascript:;" <c:if test="${page.currPage > 1 }">onclick="page1(‘${page.currPage - 1}‘)"</c:if> >上頁</a>        <!-- 下頁按鈕,跳轉到下一頁 -->     <c:if test="${page.currPage >= page.totalPage }"></c:if>     <a href="javascript:;" <c:if test="${page.currPage < page.totalPage }">onclick="page1(‘${page.currPage + 1}‘)"</c:if> >下頁</a>        <!-- 末頁按鈕,跳轉到最後一頁 -->     <c:if test="${page.currPage >= page.totalPage }"></c:if>     <a href="javascript:;" <c:if test="${page.currPage < page.totalPage }">onclick="page1(‘${page.totalPage}‘)"</c:if> >末頁</a>    </p>    </div>

jsp前端實現分頁代碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.