1、导入相关的jar包
在pom.xm中加入
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.10</version>
</dependency>
2、在Mybatis的配置文件mybatis-config.xml中加入以下代码
<plugins>
<!-- com.github.pagehelper为PageHelper类所在包名 -->
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!-- 使用下面的方式配置参数,后面会有所有的参数介绍 -->
<property name="reasonable" value="true"/>
</plugin>
</plugins>
在controller中编写代码引用
@RequestMapping(value = "/emps")
public String GetEmployees(@RequestParam(value = "pn",
defaultValue ="1")Integer pn , Model model){
PageHelper.startPage(pn,8);
List<Employee> employeeslist = employeeService.GetEmployees();
PageInfo page = new PageInfo(employeeslist,7);
model.addAttribute("pageinfo",page);
return "list";
}