Mybatis的RowBounds分页

RowBounds分页

不再使用SQL实现分页
1.接口

List getUserByRowBounds();

2.mapper.xml

3.测试

@Test
public void getUserByRowBounds(){
    SqlSession sqlSession = MybatisUtils.getSqlSession();
    //RowBounds实现
    RowBounds rowBounds = new RowBounds(1,2);
    
    //通过java代码层面实现分页
    List userList = sqlSession.selectList("com.jialidun.dao.UserDap.getUserByRowBounds",null,rowBounds);

    for(User user:userList){
        System.out.println(user);
    }

    sqlSession.close();

}

你可能感兴趣的:(mybatis)