Hi,
I have looking at how to use the Jersey API and the @QueryParam using
the StorageService example.
I have the following method:
@UriTemplate("/solutions")
@ProduceMime("application/xml")
@ConsumeMime("application/xml")
public class SolutionsResource {
.....
@HttpMethod("GET")
public Response searchSolutions(@QueryParam("q") String search,
@QueryParam("hl") String lang) {...}
....
}
Using a simple search/query string it worked no problem at all. I was
even surprised that you converted the "+" in the URI back to a space for
me (excellent I thought I was going to have to do that myself). My
example was:
"query message" is:
/solutions?hl=en&q=query+message
I receive:
search: "query message"
lang: "en"
I then started playing around with other simple query/search strings. I
used the google substitutions for different symbols i.e.:
space ==> "+"
"+" ==> "%2B"
"&" ==> "%26"
"|" ==> "%7C"
These are the observations I made:
====================================================================
_Example 1_
"query + message" is:
/soultion?hl=en&q=query+%2B+message
I receive:
search: "query message" (3 spaces)
lang: "en"
So the "+" is not preserved
_Example 2_
"query & message" is:
/solutions?hl=en&q=query+%26+message
I receive:
search: "query"
lang: "en"
So the second part of the message (namely the & and word "message" is
missing)
_Example 3
_"query || message"
/solutions?hl=en&q=query+%7C%7C+message
It works, I receive:
search: "query || message"
lang: "en"
===================================================================
From these observations I have a some questions.
Firstly are observations made in Example 1 and Example 2 bugs or are you
using other symbols to represent "&" and "+" ?.
Also it seems that my method can have many different QueryParams, at the
moment I only have two but I could see myself extending this. Do you
have any guidelines on the maximum number of QueryParams a method should
have and the consequent performance impact ?.
Regards
James