打印显示java中http请求request中所有参数

2025-10-27 22:16:41

1、通过HttpServletRequest获取请求对象request

打印显示java中http请求request中所有参数

2、将request中请求参数打印出

打印显示java中http请求request中所有参数

3、代码如下:@SuppressWarnings({ "rawtypes" })    private void showParams(HttpServletRequest request) {        Map<String, String> map = new HashMap<String, String>();                Enumeration paramNames = request.getParameterNames();        while(paramNames.hasMoreElements()) {            String paramName = (String) paramNames.nextElement();            String[] paramValues = request.getParameterValues(paramName);            if (paramValues.length == 1) {          民案      if ( paramValues[0].length() != 0) {  游肤惹                  map.put(paramName,  paramValues[0]);                }          罩边  }        }        //打印map所有值        Set<Map.Entry<String, String>> set = map.entrySet();        Logger.info("===========================");        for (Map.Entry entry : set) {            Logger.info(entry.getKey() + ":" + entry.getValue());        }        Logger.info("===========================");    }

 Logger.info------可以通过sysout打印

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢