Is there Apache utility that takes Query String and some encoding and return Map of key,value[] url decoded?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s deprecated, but you can use HttpUtils.parseQueryString.
It maps parameter names to values. If the parameter appears more than once, the value is an array.
EDIT: The above method is deprecated because it doesn’t allow you to specify character encoding.
The HttpClient project at apache has the classes you need to achieve this.
Use URIUtil.decode(String data, String encoding) to decode the query string.
Then ParameterParser.parse(String query, char separator) to get a list of NameValuePairs. You can then put these into a Commons Collections MultiMap, keyed by parameter name. (You could use a regular hash map, but that involves more code to handle multiple values per key.)