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();}