0
点赞
收藏
分享

微信扫一扫

ServletRequest 【专题】

鱼满舱 2022-12-15 阅读 113

 

获取所有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使用过滤器实现客户每次访问自登陆一次 

​​Spring-boot 配置Aop获取controller里的request中的参数以及其返回值​​

 

​​spring mvc DispatcherServlet详解之前传---前端控制器架构​​

 

​​spring boot实现超轻量级网关(反向代理、转发)​​

 

​​关于httpservletrequest的获取真实的ip​​

 

​​Spring MVC之源码速读之RequestMappingHandlerAdapter​​

 

​​Spring中的Interceptor 拦截器 专题​​

 

 

 

 

 



举报

相关推荐

0 条评论