Mybatis——分页

8.1 使用Limit分页

1.接口

//分页
List<User> getUserByLimit(Map<String,Integer> map);

2.Mapper.xml

<select id="getUserByLimit" parameterType="map" resultMap="UserMap">
  select * from user limit #{startIndex},#{pageSize}
</select>

3.测试

@Test
public void Test3(){
   SqlSession sqlSession = MybatisUtils.getSqlSession();
   UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
   HashMap<String, Integer> map = new HashMap<String, Integer>();
   map.put("startIndex",0);
   map.put("pageSize",2);
   List<User> userList = userMapper.getUserByLimit(map);
   for (User user : userList) {
       System.out.println(user);
  }
   sqlSession.close();

}

 

8.2RowBounds实现分页

了解

8.3分页插件

了解

 

posted @ 2020-08-31 19:07  Fabulo  阅读(121)  评论(0)    收藏  举报