网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

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

时间:2024-10-13 11:43:33

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

© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com