分页显示功能函数的核心 代码主要参考思路
package org.utils;import java.util.List;import org.entity.Student;/*** * @author 24519* 分页的工具类**/
public class PageUtils {//页大小(每页显示多少条记录)private int pageSize;//当前页private int currIndex;//总记录数private int totalCount;//总页数private int totalPage;//每页显示的数据List<Student> sList;public int getPageSize() {return pageSize;}public void setPageSize(int pageSize) {this.pageSize = pageSize;}public int getCurrIndex() {return currIndex;}//设置当前页public void setCurrIndex(int currIndex) {//判断当前页是否小于0,如果是,则默认第一页if(currIndex<=0){this.currIndex = 1;}else{this.currIndex = currIndex;}}public int getTotalCount() {return totalCount;}//计算总页数public void setTotalCount(int totalCount) {this.totalCount = totalCount;int pages = totalCount%pageSize==0?totalCount/pageSize:totalCount/pageSize+1;totalPage = pages;}public int getTotalPage() {return totalPage;}public void setTotalPage(int totalPage) {this.totalPage = totalPage;}public List<Student> getsList() {return sList;}public void setsList(List<Student> sList) {this.sList = sList;}}