獲取分頁總數

public static void main(String[] args) {
    int page = 19; // 總條數(模擬總數)
    int count = 31; // 總條數(模擬總數)
    int pageSize = 5; //每頁顯示條數
    for (int i = page; i <= count; i++) {
        System.out.println("總條數[" + i + "]" + "\t每頁顯示條數[" + pageSize + "]\t總頁數:" + getPageCount(i, pageSize));
    }
}

/**
 * <h5>功能:獲取總頁數</h5>
 * 
 * @param count 記錄總數
 * @param pageSize 每頁記錄數量
 * @return 
 */
public static int getPageCount(int count, int pageSize){
    return count/pageSize + (count%pageSize%pageSize > 0 ? 1 : 0);
}

如圖:
獲取分頁總數

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章