@RequestMapping("/queryUserListByPageNativeQuery") public String queryUserListByPageNativeQuery(Model model,@RequestParam(value = "page", defaultValue = "0") Integer page, @RequestParam(value = "size", defaultValue = "2") Integer size) { Page<User> users=userService.queryUserListByPageNativeQuery("c%",page, size); model.addAttribute("users", users); return "user/list1"; } @Query(value="SELECT id,username,password,age FROM User where username LIKE ?1", countQuery = "SELECT count(*) FROM User where username LIKE ?1") Page<User> queryUserListByPageNativeQuery(String userName,Pageable pageable); public Page<User> queryUserListByPageNativeQuery(String userName,Integer page,Integer size); @Override public Page<User> queryUserListByPageNativeQuery(String userName, Integer page, Integer size) { Pageable pageable = new PageRequest(page, size, Sort.Direction.ASC, "id"); return userRepository.queryUserListByPageNativeQuery(userName, pageable); }
https://www.cnblogs.com/yang-yang-yang/p/8535643.html
JPA中的Page与Pageable
https://blog.csdn.net/u011781521/article/details/74539330
https://blog.csdn.net/u012702547/article/details/53946440