ServletRequest 【专题】
获取所有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; }
获取所有QueryString参数
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; }
获取所有Cookie信息
/** * 获取所有Cookie信息 * * @param cookies * @return */ private String collectAllCoolies(Cookie[] cookies) { if (cookies != null) { StringBuilder content = new StringBuilder(); Arrays.stream(cookies).filter(Objects::nonNull).forEach(cookie -> { content.append(" [ ") .append(cookie.getName()).append(" : ").append(cookie.getValue()) .append(" ] "); }); return content.toString(); } return ""; }
基于cookie使用过滤器实现客户每次访问自登陆一次
https://www.cnblogs.com/softidea/p/6946776.html