我刚接触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;
}
当我测试该URL时,我的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制作可分页请求的良好示例,对我来说将是一个很大的帮助。