时间:2022-12-03 12:10:03 | 栏目:JAVA代码 | 点击:次
减少数据的处理量
select * from user limit startIndex,pageSize; # 注意是从startIndex+1开始查询 pageSize 个 select * from user limit 3; # [0,3]
UserMapper.java
// limit实现分页 Map后面只能是 Integer 包装类 不可以 int List<User> getUserByLimit(Map<String, Integer> map);
<select id="getUserByLimit" resultMap="com.tian.pojo.User" parameterType="map"> select * from mybatis.user limit #{statrIndex},#{pageSize}; </select>
UserMapperTest.java
<select id="getUserByLimit" resultMap="UserMap" parameterType="map"> select * from `mybatis`.`user` limit #{startIndex},#{pageSize}; </select> <select id="getUserById" resultMap="UserMap"> select * from `mybatis`.`user` where id = #{id}; </select>
执行结果: