Reputation: 409
So, I have a QueryParam that could possibly have an ampersand in it, is there any way I can override the default behavior that REST takes in parsing the URL to have it accept an ampersand? Function Header is:
@GET
@PATH("/{id}/")
@Produces(MediaType.APPLICATION_JSON)
public Response getCoverage(
@PathParam(COVERAGE_ID_DEFAULT_VALUE) String id,
@QueryParam(PROFILE_PARAM_VALUE) List <string> profiles)
I'm wondering if there is any way I can make it so that profiles can have a string that contains an ampersand in it.
I think I should clarify a bit, I'm not sure how to encode the parameters when I have a user just type into their URL bar.
http://whatever.com/3/?ParamInQuestion=Matt&Jay
I don't know where in the code I can intercept the URL to cleanse the ampersand.
Upvotes: 1
Views: 986
Reputation: 5995
You can have anything you want in your query parameters as long as those are properly escaped. See URLEncoder for details.
I believe that JAX RS or whatever you use should automatically decode the value so the getCoverage method in your case will receive decoded value.
Or your question is actually about passing multiple values so you'll get a List of values?
Upvotes: 0
Reputation: 692081
You just need to make sure that the ampersand is correctly encoded. Every request parameter should systematically be.
See the <c:url>
and <c:param>
JSP tags, and the URLEncoder class, for example.
Upvotes: 1