mybatis 分页
作者:互联网
语法:select * from user limit startIndex,pageSize
select * from user limit 0,2
mybatis分页查询
-
添加接口
// 分页查询
List<User> getUserListLimit(Map<String,Object> value); -
映射绑定
<select id="getUserListLimit" parameterType="map" resultMap="userResultMap">
select * from `user` limit #{startIndex},#{pageSize}
</select> -
测试
@Test
public void TestLimit(){
SqlSession sqlSession = MybatisUntil.getSqlSession();
UserMapper mapper = sqlSession.getMapper(UserMapper.class);
Map<String, Object> stringObjectHashMap = new HashMap<String, Object>();
stringObjectHashMap.put("startIndex",0);
stringObjectHashMap.put("pageSize",2);
List<User> userListLimit = mapper.getUserListLimit(stringObjectHashMap);
for (User user : userListLimit) {
logger.info(user.toString());
}
sqlSession.close();
}
标签:分页,pageSize,sqlSession,startIndex,user,mybatis,select,stringObjectHashMap 来源: https://www.cnblogs.com/zsqdtz/p/16686953.html