Java. How to get all the parameters from URL, but nothing more -
i want parameters values part of url:
https://ga.acriss.com:8844/arranger/ctx4434001/html/core/maintain/schedule?datefrom=2015-03-27&dateto=2015-04-27#!schedule
the parameter names arbitrary, , can 0 or many. in case above interested in "datefrom" , "dateto". closest thing found this:
vaadinrequest vaadinrequest = vaadinservice.getcurrentrequest(); for(string key: vaadinrequest.getparametermap().keyset()){ vaadinrequest.getparametermap().get(key); }
indeed gives parameters want unfortunately lot of other stuff theme, v-appid,
etc..
is there elegant solution gives parameters present in url(even if don't know name) not give not part of url? of course can take stuff , eliminate not present in url wonder if there better.
here go,
public static map<string, string> getquerymap(string query) { string[] params = query.split("&"); map<string, string> map = new hashmap<string, string>(); (string param : params) { string name = param.split("=")[0]; string value = param.split("=")[1]; map.put(name, value); } return map; }
map keys has parameters , map value has values. retrieve whatever need. in case, keys map.keyset()
.
Comments
Post a Comment