分页本质上还是查询,就是sql语句和要传的参数不一样罢了
1、接口方法
//分页
List getUserByLimit(Map map);
2、Mapper.xml配置文件
3、实现
public void getUserByLimit(){
SqlSession sqlSession = sqlSessionFactory.getsqlSession();
userMapper mapper = sqlSession.getMapper(userMapper.class);
HashMap map = new HashMap();
map.put("pageIndex",0);
map.put("pageSize",2);
List userLimit = mapper.getUserByLimit(map);
for (User user : userLimit) {
System.out.println(user);
}
}
当然分页不止这点东西,还有RowBounds这类的工具,但本质还是Limit分页