1. package com.wzy.bootmtp.test;
    2. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
    3. import com.wzy.bootmtp.mapper.UserMapper;
    4. import com.wzy.bootmtp.pojo.User;
    5. import org.junit.Test;
    6. import org.junit.runner.RunWith;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.boot.autoconfigure.SpringBootApplication;
    9. import org.springframework.boot.test.context.SpringBootTest;
    10. import org.springframework.test.context.junit4.SpringRunner;
    11. import java.util.List;
    12. @RunWith(SpringRunner.class)
    13. @SpringBootTest
    14. public class TestSpringBoot {
    15. @Autowired
    16. private UserMapper userMapper;
    17. @Test
    18. public void test2(){
    19. Page<User> page = new Page<>(1,5);
    20. userMapper.selectPage(page, null);
    21. page.getRecords().forEach(System.out::println);//每页数据list集合
    22. System.out.println("当前页:" + page.getCurrent());
    23. System.out.println("总页码:" + page.getPages());
    24. System.out.println("每页显示数据的个数:" + page.getSize());
    25. System.out.println("总记录数:" + page.getTotal());
    26. System.out.println("是否有下一页:" + page.hasNext());
    27. System.out.println("是否有上一页:" + page.hasPrevious());
    28. }
    29. }

    image.png