GET in JAX-RS with multiple parameters separated by &

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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 ids


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.





If you want multiple int values, use int. That seems fairly obvious, right?
– Andreas
1 hour ago


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.

Popular posts from this blog

C# - How to create a semi transparent or blurred backcolor on windows form

Will Oldham

Makefile test if variable is not empty