0

Is there a way to get any query parameter without explicitly declaring its name using the @QueryParam annotation?

I have a string which may have tokens like {animal}, which are then replaced by the query parameter posted, e.g. ?animal=fox, but I want the name of the token to be configurable as well. Ideally I would like to be able to do something like this:

for (QueryParam param : queryParams) {
    text = text.replaceAll("{" + param.key + "}", param.value);
}
Zoltán
  • 21,321
  • 14
  • 93
  • 134

1 Answers1

1

(I'm guessing you are talking about writing a resource to accept a query string correct?)

In which case, in your method, you can use @Context to get a UriInfo object which you an use to obtain a MultivaluedMap of all of your query string parameters.

Charlie
  • 7,181
  • 1
  • 35
  • 49