Andrei
Andrei

Reputation: 21

Spring Data Rest 2.4 doesn't work with {?page,size,sort} links

I've faced with the following problem:

Spring Data Rest version: org.springframework.data:spring-data-rest-webmvc:2.4.0.RELEASE

When i perform the query: http://localhost:8080/data/entities/ - the base query for my Rest servlet. It produces the links for all entities i have. The links has the following standard form:

"entityA": {
        "href": "http://localhost:8080/data/entities/entitiA{?page,size,sort}",
        "templated": true
    }

When i try to perform the generated link:

http://localhost:8080/data/entities/entitiA{?page,size,sort}

I have 404 NotFound exception.

But when i execute

http://localhost:8080/data/entities/entitiA

it works fine.

Do you have any ideas about it or could you suggest any solution to execute links in the format:

http://localhost:8080/data/entities/entitiA{?page,size,sort}

Thanks!

Upvotes: 1

Views: 2088

Answers (1)

Mathias Dpunkt
Mathias Dpunkt

Reputation: 12184

Sometimes it is worth to look at the documentation ;-) http://docs.spring.io/spring-data/rest/docs/2.4.0.RELEASE/reference/html/#paging-and-sorting

{?page,size,sort} is a template. It tells you which request parameters the resource supports. You are not supposed to use a templated link as it is in the response - you expand it first.

So a request like this should be working http://localhost:8080/cars/data/entities/entitiA?page=1&size=20

Upvotes: 2

Related Questions