RowBounds分页

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

List<User> getUserByRowBounds();

2.mapper.xml

<select id="getUserByRowBounds" resultMap="UserMap">
    select * from mybatis.user
</select>

3.测试

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

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

    sqlSession.close();

}

RYGAR
1 声望0 粉丝

引用和评论

0 条评论