在xml中只需要需要写如下的代码即可实现分页:
<select id="selectUserList" parameterType="map" resultType="com.test.mybatisplus.pojo.User"> SELECT <include refid="Base_Column_List" /> FROM user WHERE name LIKE CONCAT("%",#{name},"%") </select>
调用方法
/** * 分页插件 */ public static void testPageListUser() { Page<User> page = new Page<User>(1,10); Map<String, Object> condition=new HashMap<String, Object>(); condition.put("name", "测试"); //String name="测试"; List<User> lstUser = userDao.selectUserList(page,condition); for(User user:lstUser) { System.out.println(user); } }
感谢此文章作者:https://blog.csdn.net/BtWangZhi/article/details/79098420
贡献一波自己的代码
1、调用: Page<CarView> page = new Page<CarView>(current, limit); List<CarView> pageList = baseMapper.queryCarPage(page, params); page.setRecords(pageList);
return new PageUtils(page);
2、Dao
/** * 查询数据分页 * * @param page * @param params * @return */ List<CarView> queryCarPage(Page<CarView> page, Map<String, Object> params);
3、xml 后面自己传递的传输参数配置就可以了
<!--查询车辆数据分页--> <select id="queryCarPage" parameterType="map" resultType="io.sale.modules.sale.entity.dto.CarView"> SELECT sl_car.id,sl_car.customer_id,sl_car.number,sl_car.type,sl_car.frame,sl_car.annual_time,sl_car.service_time,sl_car.driver_name, sl_car.owner_phone,sl_car.image,sl_car.ramark,sl_car.dept_id,sl_car.user_id,sl_car.add_time,sl_car.del_flag,sl_car.`change`,sl_car.add_user FROM sl_car , sl_sale where sl_car.del_flag=0 GROUP BY sl_car.id </select>
原文地址:https://www.cnblogs.com/louby/p/9124071.html
时间: 2024-10-10 04:49:08