如何获得request中的全部参数

  1. private void showParams(HttpServletRequest request) {  
  2.         Map map = new HashMap();  
  3.         Enumeration paramNames = request.getParameterNames();  
  4.         while (paramNames.hasMoreElements()) {  
  5.             String paramName = (String) paramNames.nextElement();  
  6.   
  7.             String[] paramValues = request.getParameterValues(paramName);  
  8.             if (paramValues.length == 1) {  
  9.                 String paramValue = paramValues[0];  
  10.                 if (paramValue.length() != 0) {  
  11.                     map.put(paramName, paramValue);  
  12.                 }  
  13.             }  
  14.         }  
  15.   
  16.         Set<Map.Entry<String, String>> set = map.entrySet();  
  17.         System.out.println("------------------------------");  
  18.         for (Map.Entry entry : set) {  
  19.             System.out.println(entry.getKey() + ":" + entry.getValue());  
  20.         }  
  21.         System.out.println("------------------------------");  
  22.     }  

转载