1、方法
private Map showParams(HttpServletRequest request) { Map map = new HashMap(); Enumeration paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); String[] paramValues = request.getParameterValues(paramName); if (paramValues.length == 1) { String paramValue = paramValues[0]; if (paramValue.length() != 0) { map.put(paramName, paramValue); } } } return map; }
2、调用
Set<Map.Entry<String, String>> set=showParams(request).entrySet(); for (Map.Entry entry : set) { if(!entry.getKey().toString().equals("submit")){ System.out.println( entry.getKey().toString()+"+"+entry.getValue().toString()); } }