java拦截器获取请求完整参数

2020-12-13 03:51

阅读:500

标签:void   获取   after   技术   handler   http   handle   div   value   

public class OptLogAspect implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        Map ParameterMap =  httpServletRequest.getParameterMap();
        Map reqMap = new HashMap();
        Set> entry = ParameterMap.entrySet();
        Iterator> it = entry.iterator();
        while (it.hasNext()){
            Map.Entry  me = it.next();
            String key = me.getKey();
            String value = me.getValue()[0];
            reqMap.put(key,value);
        }
        String queryString = JsonUtils.toJson(reqMap);
        System.out.println(queryString);
        return true;
    }
    
    @Override
    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
    }
    
    @Override
    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
    }
}

get请求和post请求都可以完整获取 技术图片

 

java拦截器获取请求完整参数

标签:void   获取   after   技术   handler   http   handle   div   value   

原文地址:https://www.cnblogs.com/SimonHu1993/p/11090523.html


评论


亲,登录后才可以留言!