Use enumeration to get the request parameters passed from the front end

When the number of passed parameters is not fixed and the parameter names are not repeated, the method of obtaining the value:

//Get the parameter name of the enumeration type, if the parameter name is repeated, only the first one can be obtained

  1. Map map = new HashMap();

  2. Enumeration enum =this.getRequest().getParameterNames();  
  3.  while (enum.hasMoreElements()) {  
  4.   String paramName = (String) enum.nextElement();  
  5.    
  6.   String paramValue = this.getRequest().getParameter(paramName);  
  7.    / / Form the map corresponding to the key value  
  8.   map.put(paramName, paramValue);  
  9.   }  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324572651&siteId=291194637