The following solution is based on the answer provided by @palisade, but addresses the problem of pagination parameters not appearing in the self link--a problem noted by two of the answer's commenters, and which I experienced myself.
By replacing palisade's link declaration...
Link link = linkTo(methodOn(OfferController.class).findOfferById(offerId,
pageable,
pagedResourcesAssembler)).withSelfRel();
...with the following...
Link link = new Link(ServletUriComponentsBuilder.fromCurrentRequest().build()
.toUriString())
.withSelfRel();
...I'm getting page links that look like this:
{
"links": [
{
"rel": "first",
"href": "http://[your host]/[your app context]/offer/search/findById?offerId=[some offer id]&page=0&size=1"
},
{
"rel": "prev",
"href": "http://[your host]/[your app context]/offer/search/findById?offerId=[some offer id]&page=2&size=1"
},
{
"rel": "self",
"href": "http://[your host]/[your app context]/offer/search/findById?offerId=[some offer id]&page=3&size=1"
},
{
"rel": "next",
"href": "http://[your host]/[your app context]/offer/search/findById?offerId=[some offer id]&page=4&size=1"
},
{
"rel": "last",
"href": "http://[your host]/[your app context]/offer/search/findById?offerId=[some offer id]&page=6&size=1"
}
],
"content": [
{
...
Link link = new Link(entityLinks.linkFor(Inventory.class, "name","page","size","sort").toString() + "/search/categoryName{?name,page,size,sort}").withSelfRel()
. I'm going to take another stab at it and see if I can get it to work like yours, but for now I'm happy that it's working. – Largeminded