Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

分页取数据时,如果数据一条都没有返回, pageInfo.isIsLastPage(); 返回false #50

Closed
JingDas05 opened this issue May 10, 2017 · 3 comments
Milestone

Comments

@JingDas05
Copy link

 int offset = 0;
        boolean isLast = false;

        while (!isLast) {
            PageHelper.offsetPage(offset, LIMIT);
            PageInfo<Gjc> pageInfo = new PageInfo<>(gjcMapper.getGjcs());
            for (Gjc gjc : pageInfo.getList()) {
                redisService.set(GJC.concat(gjc.getGjc()), String.valueOf(gjc.getBh()));
            }
            isLast = pageInfo.isIsLastPage();
            offset = offset + LIMIT;
        }

代码如上
gjcMapper.getGjcs()
数据库一条数据都没有,取回的时候
isLast = pageInfo.isIsLastPage(); 的标志位始终为false

@JingDas05
Copy link
Author

JingDas05 commented May 10, 2017

查看了源码 是PageInfo 这个类里面下面的方法 加了一个判断pages == 0就好了,帮忙看下,谢谢

private void judgePageBoudary() {
        isFirstPage = pageNum == 1;
        isLastPage = pageNum == pages || pages == 0;
        hasPreviousPage = pageNum > 1;
        hasNextPage = pageNum < pages;
    }

@abel533
Copy link
Collaborator

abel533 commented May 10, 2017

今天会发布一个5.0.2-beta版本,如果方便可以帮忙测试这个版本。

@JingDas05
Copy link
Author

@abel533 好的

@abel533 abel533 closed this as completed May 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants