'How to change Spring HATEOAS PagedResourcesAssembler default self, prev, next, last links format
I'm working with PagedModel and PagedResourcesAssembler and everything is great! Everything is working except for its default link generation that is adding a peace of wrong information. When requesting for all entities I get:
{
"_embedded": {
"users": [
{
"id": 2,
"firstName": "Luis",
"lastName": "Santini",
"email": "[email protected]",
"profilePictureUrl": null,
"creationDate": "2022-03-09T08:40:50.279699",
"lastUpdated": "2022-03-09T08:40:50.279699",
"_links": {
"self": {
"href": "http://localhost:8080/users/2"
}
}
}
]
},
"_links": {
"first": {
"href": "http://localhost:8080/users?page=0&size=1&sort=id,asc"
},
"self": {
"href": "http://localhost:8080/users?page=0&size=1&sort=id,asc"
},
"next": {
"href": "http://localhost:8080/users?page=1&size=1&sort=id,asc"
},
"last": {
"href": "http://localhost:8080/users?page=4&size=1&sort=id,asc"
}
},
"page": {
"size": 1,
"totalElements": 5,
"totalPages": 5,
"number": 0
}
}
I don't want to add that comma asc: "sort=id,asc" at the end of each link, because that's not how I'm supporting pagination. If provided, the query params follows this format so pagination can be done:
page=0&size=1&sort=id&order=asc
So it's necessary to add 'order' before '=asc'.
So how can I remove that comma asc at the end, or add the 'order='?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
