获取所有header
private static Map<String, String> getHeaders(HttpServletRequest request) {
Map<String, String> headerMap = new HashMap<>();
Enumeration<String> enumeration = request.getHeaderNames();
while (enumeration.hasMoreElements()) {
String name = enumeration.nextElement();
String value = request.getHeader(name);
headerMap.put(name, value);
}
return headerMap;
}
获取所有参数
private static Map<String, String> getParameters(HttpServletRequest request) {
Map<String, String> parameterMap = new HashMap<>();
Enumeration<String> enumeration = request.getParameterNames();
while (enumeration.hasMoreElements()) {
String name = enumeration.nextElement();
String value = request.getParameter(name);
parameterMap.put(name, value);
}
return parameterMap;
}
版权声明:本文为ai249841929原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。