I want to have all query parameters in a list. As well those that were not used in the get method. My method:
@GET
@Produces({"text/csv"})
@Path("/somesearch/")
public Response method1(
@DefaultValue("0") @QueryParam("param1") float param1,
@DefaultValue("0") @QueryParam("param2") float param2,
// further optional parameters... not only floats){
ArrayList<Object> parameters = new ArrayList<Object>();
parameters.add(param1);
parameters.add(param2);
// add further query parameters
// do something ...
}
so is there a possibility to obtain all the parameters (even those not set in the GET request) in a list? I can't use the @context uriInfo with its getQueryParameters() method because it lists the parameters used in the url
Not sure about the @DefaultValue annotation, but if I had to do it I would have done it something like this..
@GET
@Produces({"text/csv"})
@Path("/somesearch/")
public Response method1(@Context UriInfo uriInfo){
MultivaluedMap<String, String> multiParameters = uriInfo.getQueryParameters();
// multiParameters contains all the parameters in key-value pairing format
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.