分页插件pagehelper 引入和应用
2023-03-20 本文已影响0人
笨的很想飞
1.pom 引入
<!-- pagehelper 分页插件-->
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.10</version>
</dependency>
2.应用
StudentDAO studentDAO = MyBatisUtil.getMapper(StudentDAO.class);
PageHelper.startPage(1,1);
List<Student> students = studentDAO.listStudentsByGender("女");
PageInfo<Student> pageInfo = new PageInfo<Student>(students);
// pageInfo 数据及分页信息
for (Student s:
pageInfo.getList()) {
System.out.println(s);
}