abel533 / Mybatis-Spring

这是一个集成了Mybatis分页插件和通用Mapper的示例项目
941 stars 610 forks source link

springBoot1.5.9+pagehelper5.0每页显示数量居然等于总记录数?! #34

Open stwen opened 6 years ago

stwen commented 6 years ago

springBoot1.5.9+mybatis+oracle+pagehelper5.0

public PageInfo(List<T> list, int navigatePages) {
        super(list);
        if (list instanceof Page) {
            Page page = (Page) list;
            this.pageNum = page.getPageNum();
            this.pageSize = page.getPageSize();

            this.pages = page.getPages();
            this.size = page.size();
            //由于结果是>startRow的,所以实际的需要+1
            if (this.size == 0) {
                this.startRow = 0;
                this.endRow = 0;
            } else {
                this.startRow = page.getStartRow() + 1;
                //计算实际的endRow(最后一页的时候特殊)
                this.endRow = this.startRow - 1 + this.size;
            }
        }else if (list instanceof Collection) {
            this.pageNum = 1;
            this.pageSize = list.size();

            this.pages = this.pageSize > 0 ? 1 : 0;
            this.size = list.size();
            this.startRow = 0;
            this.endRow = list.size() > 0 ? list.size() - 1 : 0;
        }
        if (list instanceof Collection) {
            this.navigatePages = navigatePages;
            //计算导航页
            calcNavigatepageNums();
            //计算前后页,第一页,最后一页
            calcPage();
            //判断页面边界
            judgePageBoudary();
        }
    }
abel533 commented 6 years ago

说明你的代码没有真正进行分页,你可以看 SQL 日志。

最有可能的情况就是分页插件没配置对,没起作用。