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

时间:2026-02-14 00:06:09

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打印

© 2026 一点知道
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com