免费高清特黄a大片,九一h片在线免费看,a免费国产一级特黄aa大,国产精品国产主播在线观看,成人精品一区久久久久,一级特黄aa大片,俄罗斯无遮挡一级毛片

分享

WEB開發(fā)中Struts分頁(yè)算法

 rrliu 2011-02-09
WEB開發(fā)中Struts分頁(yè)算法作者:本站原創(chuàng)發(fā)布時(shí)間:2010-06-25來源:JAVA中文網(wǎng) 點(diǎn)我投稿
教程由JAVA中文網(wǎng)整理校對(duì)發(fā)布()
/**
* 分頁(yè)算法
*/
package cn.eshore.user.util;
public class PageBean {
private int currentPage = 1;// 當(dāng)前頁(yè)數(shù)
public int totalPages = 0;// 總頁(yè)數(shù)
private int pageSize = 0;// 每頁(yè)顯示數(shù)
private int totalRows = 0;// 總數(shù)據(jù)數(shù)
private int startNum = 0;// 開始記錄
private int nextPage = 0;// 下一頁(yè)
private int previousPage = 0;// 上一頁(yè)
private boolean hasNextPage = false;// 是否有下一頁(yè)
private boolean hasPreviousPage = false;// 是否有前一頁(yè)
public PageBean(int pageSize, int currentPage, int totalRows) {
this.pageSize = pageSize;
this.currentPage = currentPage;
this.totalRows = totalRows;
if ((totalRows % pageSize) == 0) {
totalPages = totalRows / pageSize;
} else {
totalPages = totalRows / pageSize + 1;
}
if (currentPage >= totalPages) {
hasNextPage = false;
currentPage = totalPages;
} else {
hasNextPage = true;
}
if (currentPage <= 1) {
hasPreviousPage = false;
currentPage = 1;
} else {
hasPreviousPage = true;
}
startNum = (currentPage - 1) * pageSize;
nextPage = currentPage + 1;
if (nextPage >= totalPages) {
nextPage = totalPages;
}
previousPage = currentPage - 1;
if (previousPage <= 1) {
previousPage = 1;
}
}
public boolean isHasNextPage() {
return hasNextPage;
}
public boolean isHasPreviousPage() {
return hasPreviousPage;
}
/**
* @return the nextPage
*/
public int getNextPage() {
return nextPage;
}
/**
* @param nextPage
* the nextPage to set
*/
public void setNextPage(int nextPage) {
this.nextPage = nextPage;
}
/**
* @return the previousPage
*/
public int getPreviousPage() {
return previousPage;
}
/**
* @param previousPage
* the previousPage to set
*/
public void setPreviousPage(int previousPage) {
this.previousPage = previousPage;
}
/**
* @return the currentPage
*/
public int getCurrentPage() {
return currentPage;
}
/**
* @param currentPage
* the currentPage to set
*/
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
/**
* @return the pageSize
*/
public int getPageSize() {
return pageSize;
}
/**
* @param pageSize
* the pageSize to set
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
/**
* @return the totalPages
*/
public int getTotalPages() {
return totalPages;
}
/**
* @param totalPages
* the totalPages to set
*/
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
/**
* @return the totalRows
*/
public int getTotalRows() {
return totalRows;
}
/**
* @param totalRows
* the totalRows to set
*/
public void setTotalRows(int totalRows) {
this.totalRows = totalRows;
}
/**
* @param hasNextPage
* the hasNextPage to set
*/
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
/**
* @param hasPreviousPage
* the hasPreviousPage to set
*/
public void setHasPreviousPage(boolean hasPreviousPage) {
this.hasPreviousPage = hasPreviousPage;
}
/**
* @return the startNum
*/
public int getStartNum() {
return startNum;
}
/**
* @param startNum
* the startNum to set
*/
public void setStartNum(int startNum) {
this.startNum = startNum;
}
}
如果你使用的是struts,那么你在調(diào)用這個(gè)PageBean分頁(yè)算法之前,你得先取得對(duì)你所想要進(jìn)行分頁(yè)的數(shù)據(jù)的總記錄數(shù),然后你就實(shí)例化這個(gè)PageBean,之后你就可以通過get方法得到任何你想要的值。
package test;
import cn.eshore.user.util.PageBean;
public class Test extends DispatchAction{
......
public ActionForward loadPageUser(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
.......
int pageSize = 5;
String pageId = request.getParameter("pageId");
if (pageId == null || pageId.equals("")) {
pageId = "1";
}
int currentPage = Integer.parseInt(pageId);
//從服務(wù)層里得到用戶的總記錄數(shù)
int totalRows = userService.getTotalRows();
PageBean page = new PageBean(pageSize, currentPage, totalRows);
....
}
}
 
WEB開發(fā)中Struts分頁(yè)算法(本教程僅供研究和學(xué)習(xí),不代表JAVA中文網(wǎng)觀點(diǎn))
本篇文章鏈接地址:http://www./architecture/struts/252048.shtml
如需轉(zhuǎn)載請(qǐng)注明出自JAVA中文網(wǎng):http://www./
大家還都關(guān)注: Struts分頁(yè)算法
本篇文章來自Java中文網(wǎng):http://www./architecture/struts/252048.shtml

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多