主頁 > 知識庫 > jsp hibernate的分頁代碼第1/3頁

jsp hibernate的分頁代碼第1/3頁

熱門標(biāo)簽:團(tuán)購網(wǎng)站 Linux服務(wù)器 服務(wù)器配置 阿里云 科大訊飛語音識別系統(tǒng) 電子圍欄 Mysql連接數(shù)設(shè)置 銀行業(yè)務(wù)
可見使用Hibernate,在進(jìn)行查詢分頁的操作上,是具有非常大的靈活性,Hibernate會首先嘗試用特定數(shù)據(jù)庫的分頁sql,如果沒用,再嘗試Scrollable,如果不行,最后采用rset.next()移動的辦法。
(一)pager類
* @(#)Pager.java 2005-5-3
*
* Copyright (c) 2005, Jeffrey Hsu
*/
package com.jeffrey.messagelove;
/**
* Pager holds the page info.
*/
public class Pager {
private int totalRows = 0; // 記錄總數(shù)
private int totalPages = 0; // 總頁數(shù)
private int pageSize = 10; // 每頁顯示數(shù)據(jù)條數(shù),默認(rèn)為10條記錄
private int currentPage = 1; // 當(dāng)前頁數(shù)
private boolean hasPrevious = false; // 是否有上一頁
private boolean hasNext = false; // 是否有下一頁
public Pager() {
}
/**
* Initialize Pager
* @param totalRows total record rows
* @param pageSize total record is hold by every page
*/
public void init(int totalRows, int pageSize) {
this.totalRows = totalRows;
this.pageSize = pageSize;
totalPages = ((totalRows + pageSize) - 1) / pageSize;
refresh(); // 刷新當(dāng)前頁面信息
}
/**
* @return Returns the currentPage.
*/
public int getCurrentPage() {
return currentPage;
}
/**
* @param currentPage current page
*/
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
refresh();
}
/**
* @return Returns the pageSize.
*/
public int getPageSize() {
return pageSize;
}
/**
* @param pageSize The pageSize to set.
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
refresh();
}
/**
* @return Returns the totalPages.
*/
public int getTotalPages() {
return totalPages;
}
/**
* @param totalPages The totalPages to set.
*/
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
refresh();
}
/**
* @return Returns the totalRows.
*/
public int getTotalRows() {
return totalRows;
}
/**
* @param totalRows The totalRows to set.
*/
public void setTotalRows(int totalRows) {
this.totalRows = totalRows;
refresh();
}
// 跳到第一頁
public void first() {
currentPage = 1;
this.setHasPrevious(false);
refresh();
}
// 取得上一頁(重新設(shè)定當(dāng)前頁面即可)
public void previous() {
currentPage--;
refresh();
}
// 取得下一頁
public void next() {
System.out.println("next: totalPages: " + totalPages +
" currentPage : " + currentPage);
if (currentPage totalPages) {
currentPage++;
}
refresh();
}
// 跳到最后一頁
public void last() {
currentPage = totalPages;
this.setHasNext(false);
refresh();
}
public boolean isHasNext() {
return hasNext;
}
/**
* @param hasNext The hasNext to set.
*/
public void setHasNext(boolean hasNext) {
this.hasNext = hasNext;
}
public boolean isHasPrevious() {
return hasPrevious;
}
/**
* @param hasPrevious The hasPrevious to set.
*/
public void setHasPrevious(boolean hasPrevious) {
this.hasPrevious = hasPrevious;
}
123下一頁閱讀全文
您可能感興趣的文章:
  • jsp分頁顯示的實現(xiàn)代碼
  • JSP分頁顯示的實例代碼
  • 一個實用的JSP分頁代碼
  • JSP實現(xiàn)的簡單分頁示例
  • JSP自定義分頁標(biāo)簽TAG全過程
  • jsp+servlet+javabean實現(xiàn)數(shù)據(jù)分頁方法完整實例
  • JSP通用高大上分頁代碼(超管用)
  • jsp實現(xiàn)頁面分頁功能代碼
  • 一個通用的jsp分頁P(yáng)ageBean
  • JSP實現(xiàn)分頁效果

標(biāo)簽:萍鄉(xiāng) 廣元 棗莊 衡水 江蘇 衢州 大理 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《jsp hibernate的分頁代碼第1/3頁》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266