弹簧数据可分页:返回空内容
2022-09-02 22:54:38
我是Spring Data和Spring MVC的新手,我不明白为什么我会得到空内容:
@RequestMapping(value="/pages", method=RequestMethod.GET)
@ResponseBody
public Page<Client> contactsPages(@RequestParam int page, @RequestParam int size) {
Pageable pageable = new PageRequest(page, size, new Sort("id"));
Page<Client> pageResult = clientRepository.findAll(pageable);
return pageResult;
}
当我测试网址时,我的json的结果是:
{"content":[],"last":true,"totalElements":2,"totalPages":1,"size":5,"number":1,"sort":[{"direction":"ASC","property":"id","ignoreCase":false,"nullHandling":"NATIVE","ascending":true}],"first":false,"numberOfElements":0}
如果你有很好的例子,使用Spring Data和Spring MVC和AngularJS提出可分页的请求;这对我来说将是一个很大的帮助。