1、分页
接口
List<User> getUserByLimit(Map<String,Integer> map);
Mapper.XML
<!-- 分页
List<User> getUserByLimit(Map<String,Integer> map); -->
<select id="getUserByLimit" parameterType="map" resultMap="User">
select * from mybatis.user limit #{startIndex},#{pageSize}
</select>
测试
@Test
public void getUserByLimit(){
SqlSession sqlSession = MybatisUtils.getSqlSession();
UserMapper mapper = sqlSession.getMapper(UserMapper.class);
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put("startIndex",0);
map.put("pageSize",2);
List<User> userList = mapper.getUserByLimit(map);
for (User user : userList) {
System.out.println(user);
}
sqlSession.close();