robross0606
robross0606

Reputation: 577

Possible to use @RepositoryRestResource with @PathVariable instead of @Param?

I have a RestRepositoryResource which is working properly. However, I would prefer to structure URLs using path variables instead of query parameters. The goal would be this:

http://localhost/persons/findByLastName/Smith/

instead of this:

http://localhost/persons/findByLastName?lastName=Smith

I have played around with various annotations but not achieved this using RestRepositoryResource. Is this possible or does this have to be done with a Controller resource mapping?

Upvotes: 0

Views: 728

Answers (1)

theksquare
theksquare

Reputation: 131

Spring data repositories don't support the @PathVariable annotation right now. However a simple workaround for this problem might be to use URLRewriteFilter internally re-route the request for http://localhost/persons/findByLastName/Smith/ to http://localhost/persons/findByLastName?lastName=Smith without the user noticing.

Upvotes: 1

Related Questions