java后台获取URL带参demo

URL:http://aos.wall.youmi.net/v2/check_fb_sig?order=YM130402cygr_UTb42&app=30996ced018a2a5e&ad=KC%E7%BD%91%E7%BB%9C%E7%94%B5%E8%AF%9D&user=1141058&device=50ead626ae6e&chn=0&points=7&time=1364890524&sig=15b3dfe0&adid=100&pkg=abc

java后台获取URL带参demo

获取到的parameter为:
order=YM130402cygr_UTb42&app=30996ced018a2a5e&ad=KC%E7%BD%91%E7%BB%9C%E7%94%B5%E8%AF%9D&user=1141058&
device=50ead626ae6e&chn=0&points=7&time=1364890524&sig=15b3dfe0&adid=100&pkg=abc

  

java后台获取URL带参demo

SysConfigUtil.getQueryParams(parameter):如下:

public static Map<String,String> getQueryParams(String url) {
try {
Map<String, String> params = new HashMap<String, String>(); for (String param : url.split("&")) {
String[] pair = param.split("=");
String key = URLDecoder.decode(pair[0], "UTF-8");
String value = "";
if (pair.length > 1) {
value = URLDecoder.decode(pair[1], "UTF-8");
}
params.put(key, value); } return params;
} catch (UnsupportedEncodingException ex) {
throw new AssertionError(ex);
}
}

  

上一篇:xmind的第七天笔记


下一篇:Nginx 实现MySQL的负载均衡