自用 :手动分页

第一步:首先建立一个PageBean

package com.qn.jq.daomain;

import java.util.List;

/**
 * @author Lizhenye
 * @date 2019/7/30  20:04
 */
public class PageBean<T> {
    private int totalCount; //总记录数   //需要方法
    private  int totalPage; //总页数
    private List<T> list;   //每页的数据   //也要方法来设置
    private int currentPage; // 表示当前的页数
    private  int pageSize; //每页显示多少个数据

    public PageBean(int totalCount, int totalPage, List<T> list, int currentPage, int pageSize) {
        this.totalCount = totalCount;
        this.totalPage = totalPage;
        this.list = list;
        this.currentPage = currentPage;
        this.pageSize = pageSize;
    }

    public PageBean() {
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "totalCount=" + totalCount +
                ", totalPage=" + totalPage +
                ", list=" + list +
                ", currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                '}';
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}

第二步 写dao方法 用来查询总条数totalCount 以及 每一页的数据List

public interface ProductDao {
    //写一个查询一页数据的方法
    List<Product> selectList(int currentPage,int pageSize);

    //写一个查询所有条数的语句
    int selectCountProduc
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值