package com.wzy.controller;import com.github.pagehelper.PageHelper;import com.github.pagehelper.PageInfo;import com.wzy.pojo.Employee;import com.wzy.service.EmployeesService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import java.util.List;@Controllerpublic class EmployeeController { @Autowired EmployeesService employeesService; @RequestMapping(value = "/list") public String getEmployee(@RequestParam(value = "pageNumber",defaultValue = "1") Integer pageNumber, Model model) { /** * pageNumber:动态获取第几页 * 5:此处固定每页显示5条数据 */ PageHelper.startPage(pageNumber,5);//这方法下的 执行sql的方法 会分页。 List<Employee> employeesList = employeesService.getEmployeeAll(); /** * 使用pageInfo 包装查询到的信息,只需要将使用 pageInfo 交给 跳转输出的页面。 * 封装了详细的分页信息。包括我们查询出来的数据。 * 第一个参数是封装查询到的结果,第二个参数是要连续显示的页数。 */ PageInfo pageInfo = new PageInfo(employeesList); //方到域中 model.addAttribute("pageInfo",pageInfo); return "list"; }}