Resource Matching Using @QueryParams #5874
Unanswered
shelley-jean-baker
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The ambiguity of the Resource endpoints is determined by the Algorithm in Section 3.7 of the Jakarta REST Spec. This matching algorithm does not take the query parameter into account. The workaround this is very simple, just add an extra |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Why is
@QueryParam
not calculated in the resource matching?The JAX-RS specification seems to indicate that the entire URI should be used for matching resource methods:
and:
The
UriInfo
includes query as an identifying part of the URI, which is consistent with RFC 3986, which clearly includes the query as an identifying component of the resource:Given this, I would expect to be able to define two resources similar to the following, as their resource identifiers are uniquely identified by the query component, which is specified as a metadata annotation on the resource method definition:
However, attempts to do this results in an error when starting up the application, similar to the following:
Why does Jersey not take the query params into account when identifying resources?
By comparison, this can be implemented successfully in Spring as follows:
Note that I haven't tested any other JAX-RS implementations, but have used this feature in Spring in the past and was quite surprised it was not available in Jersey.
Beta Was this translation helpful? Give feedback.
All reactions