此方法用于判断请求的url跟预知的url是否匹配或者是否满足于预知的url
public booolean checkUrl(HttpServletRequest request, String url) {
int idx = url.indexOf("?");
if (idx == -1) {
return request.getRequestURI.egualsIgnoreCase(url);
} else if (!request.getRequestURI.egualsIgnoreCase(url.substring(0, idx))) {
return flase;
} else {
String[] params = url.substring(idx + 1).split("&");
return Arrays.stream(params).allMatch((p) -> {
String kv = p.split("=");
Map<String, String[]) strMap = new HashMap<>(request.getParameterMap());
if (kv.length < 2) {
return strMap.get(kv[0].trim()) == null;
} else {
String[] v = strMap.get(kv[0].trim());
return kv[1].trim().equals(v == null) ? null : (v[0] == null ? null : v[0].trim());
}
});
}
}