Spring Data JPA分页查询
May 2020
控制层
1 2 3 4 5 6 7 8 9 10 11
| @RequestMapping("/allUser") public ModelAndView listByPages(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { ModelAndView mav = new ModelAndView(); Sort sort = Sort.by(Sort.Direction.ASC, "id"); Pageable pageable = PageRequest.of(pageNum - 1, 4, sort); Page<User> users = userService.findAll(pageable); mav.addObject("allUser", users); mav.setViewName("allUser"); return mav;
}
|
业务层
1 2 3 4
| @Override public Page<User> findAll(Pageable pageable) { return userDao.findAll(pageable); }
|
发布时间: 2020-05-22 12:10:10
更新时间: 2022-04-21 16:20:23
本文链接: https://wyatt.ink/posts/Code/2d8953d4.html
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!