【MyBatis】学习笔记008--分页查询
MyBatis实现分页查询,换汤不换药,依旧是基于SQL
1.dao接口
List<User> selectUserLimit(Map<string,Integer> map);
limit用法如下:https://www.cnblogs.com/AirCL/p/14335240.html
2.Mapper配置
<select id="selectUserLimit" resultType="User" parameterType="map"> select * from user limit ${startIndex},${pageSize} </select>
3.实现
HashMap<String,Integer> map = new Map<String,Integer>(); List<User> users = userDao.selectUserLimit(map);
另,mybatis拥有一款自己的分页插件mybatis-pagehelpper,如何使用视情况而定,官网如下
https://pagehelper.github.io/