I am trying to build custom response object, but in the final response i am getting incorrect link for last element.
Any thought ?
Request :/searchx?page=2&size=5&total_required=true
Response :
"_links": {
"first": {
"href": "http://localhost:8080/v1/xx/fxy/x1/searchx?total_required=true&page=0&size=5"
},
"prev": {
"href": "http://localhost:8080/v1/xx/fxy/x1/searchx?total_required=true&page=1&size=5"
},
"self": {
"href": "http://localhost:8080/v1/xx/fxy/x1/searchx?total_required=true&page=2&size=5"
},
"last": {
"href": "http://localhost:8080/v1/xx/fxy/x1/searchx?total_required=true&page=2&size=5"
}
},
Here is the my page resource assembler.
Page<MyData> pageRs = new PageImpl<>(data, pageable, total);
response.setData(pageRs.getContent());
PagedModel<MyModel> responseModels = pagedResourcesAssembler.toModel(pageRs, datAssembler);
response.setLinks(responseModels.getLinks());
The issue was the total elements count in PageImpl class argument. After fixing that i was able to get correct page links.