is there way change existing query parameters using jersey filter. have clients passing in id's this
/v1/path?id=1,2,3
what them show list in resource class //resource class
public list<something> getfilteredlist(@queryparam("id") list<string> ids) {// right now, ids list contains 1 string 1,2,3. apply filter , change comma separated query parameters multivalued parameters resource method gets list instead.
is @ possible? tried filter query params given jersey's
containerrequestcontext.geturiinfo().getqueryparameters() is immutable.
what's way solve problem?
the best way can think of create wrapper class list. makes easier take advantage of specified functionality of jersey. can see mean @ passing custom type query parameter.
for example
public class idfilter { private list<string> ids = new arraylist<>(); public list<string> getids() { return ids; } public static idfilter valueof(string param) { idfilter filter = new idfilter(); (string id: param.split(",") { filter.getids().add(id); } } } getfilteredlist(@queryparam("id") idfilter ids) { we don't need else. having static valueof enough jersey know how parse query string.
Comments
Post a Comment