MyBatis RowBounds doesn't limit query results

后端 未结 3 1065
滥情空心
滥情空心 2020-12-29 15:42

I am developing an stateless API that needs to support pagination.

I use an Oracle database. I use Spring with MyBatis for database access.

From the docume

3条回答
  •  我在风中等你
    2020-12-29 15:56

    I tested on Postgres database and pagination from AngularUI. The first page is N°1, if you call page N°0, the services return all datas.

    java Service:

    public List selectAll(int currentPage, int itemsPerPage);
        int offset = (currentPage - 1) * itemsPerPage;
        RowBounds rowbounds;
        if(currentPage == 0){
            rowBounds = new RowBounds();
        } else {
            rowBounds = new RowBounds(currentPage, itemsPerPage);
        }
        return fooMapper.selectAll(rowBounds);
    }
    

    java Mapper:

    public List selectAll(RowBounds rowbounds);
    

    xml Mapper:

    
    

提交回复
热议问题