码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2019-06-26 16:34:42      阅读:563      评论:0      收藏:0      [点我收藏+]

标签: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<Map.Entry<String,String[]>> entry = ParameterMap.entrySet();
        Iterator<Map.Entry<String,String[]>> it = entry.iterator();
        while (it.hasNext()){
            Map.Entry<String,String[]>  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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!