转载自:Springboot中MyBatisplus使用IPage和Page分页_page和ipage_super_.的博客-CSDN博客
(1)Controller
- public class InterController {
- @Autowired
- private InterService interService;
-
- @GetMapping("/test")
- public IPage<Map> test() {
- Integer currentPage = 1; //当前页数:显示第一页数据
- Integer pageSize = 2; //每页显示多少:每页显示2条数据
- Page<Map> page = new Page<Map>(currentPage, pageSize);
- IPage<Map> findList = interService.findlistpage(page);
- return findList;
- }
- }
(2)Service
-
- @Service
- public class InterService {
- @Autowired
- private InterDao interDao;
-
- public IPage<Map> findlistpage(Page<Map> page) {
- return interDao.selectMapsPage(page, null);
- }
- }
(3)Dao
- public interface InterDao extends BaseMapper<Permission> {
- IPage<Map> selectMapsPage(Page<Map> page, QueryWrapper<List<Map<String, Object>>> wrapper);
- }
(4)XML
-
- "1.0" encoding="UTF-8"?>
- mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http#{//mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.xkcoding.rbac.security.dao.InterDao">
-
- <select id="selectMapsPage" resultType="java.util.Map" parameterType="java.util.Map">
- SELECT * FROM INTER_COLLECTION
- select>
-
- mapper>