I would like to take value of specific parameter in query string. Is there any method in HttpClient which can do if for me (ex. util class method) or I have to write my own?
2 Answers
In 4.X.X there is:
List<NameValuePair> parameters = URLEncodedUtils.parse(new URI(
request.getRequestLine().getUri()), HTTP.UTF_8);
for (NameValuePair nameValuePair : parameters) {
System.out.println(nameValuePair.getName() + ": "
+ nameValuePair.getValue());
}
Then handle your own parameter.
1 Comment
2rs2ts
There's no such method signature for
URLEncodedUtils.parse, and HTTP.UTF_8 is deprecated. Try URLEncodedUtils.parse(new URI(request.getRequestLine().getUri()).getQuery(), StandardCharsets.UTF_8);.