GET in JAX-RS with multiple parameters separated by &
GET in JAX-RS with multiple parameters separated by &
I am developing a JAX-RS backend and I would like to develop a service for GET requests like:
http://completeDoc?id=23&id=24
where the number of id is variable.
I would like some kind of @GET and @PathParam annotation to extract the List of id
s
id
So far my code looks like this:
@GET
@Path("/completeDoc")
@Produces("application/msword")
public Response getCompleteDoc(@QueryParam("id") int id) {
System.out.println(id);
return Response.status(Response.Status.NOT_FOUND).build();
}
Obviously as it is it reads only the first id.
int
int
Or
List<Integer>
.– shmosel
1 hour ago
List<Integer>
Or if you strictly follow the javadoc of
QueryParam
, use List<Integer>
, since the javadoc doesn't mention support for arrays, though arrays may work correctly depending on implementation, e.g. I believe Spring supports arrays.– Andreas
1 hour ago
QueryParam
List<Integer>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
If you want multiple
int
values, useint
. That seems fairly obvious, right?– Andreas
1 hour ago