Requirement - I have a servlet in which based on the url I need to make a webClient call.
url - https:///job/feeds?query=abc&indent=json&rows=5
The url (?query=abc&indent=json&rows=5) query parameters are not fixed it can vary based on the user requirement. So the below code is been written for the above url when they are fixed.
JAXRSClientFactoryBean client = bean(serverUrl,New ObjectMapper());
return client.createWebClient()
.path("job")
.path("feeds")
.query("indent",json)
.query("rows",5)
.query("query",abc)
.get(XYZ.class)
But I want to make the code dynamic so that based on the query parameter the .query attributes should get added to JAXRSClientFactoryBean object.
For ex -
- if i get this url (https:///job/feeds?query=abc) then only one query parameter should get added.
- if i get this url (https:///job/feeds?query=abc&indent=json) then two query parameter should get added.
So can someone please help me in making this code dynamic.
Below code I have written in case of making it dynamic.
JAXRSClientFactoryBean client = bean(serverUrl,New ObjectMapper());
WebClient wc = client.createWebClient().path("job").path("feeds");
request.getParameterMap().forEach(wc::query);
But no response is coming from the above code.