SpringMVC acquisition parameters map

// 从页面获取数据
public IMap(HttpServletRequest request) {
   this.request = request;
   // 返回值Map
HashMap  returnMap = new HashMap();
   // 参数Map
   Map properties = request.getParameterMap();
   Set<Map.Entry> entrySet = properties.entrySet();
   for (Map.Entry entry : entrySet) {
      String key = (String) entry.getKey() == null ? null : convert2Decode((String) entry.getKey(), charset);
      Object valueObj = entry.getValue();
      String value = "";
      if(null == valueObj){
         value = "";
      }else if(valueObj instanceof String[]){
         String[] values = (String[])valueObj;
         for(int i=0;i<values.length;i++){
            value = values[i];
            if (request.getMethod().equalsIgnoreCase("get")) {
               value = values == null ? null : convert2Character(value, charset);
            }
            value = values == null ? null : convert2Decode(value, charset) + ",";
         }
         value = value.substring(0, value.length()-1);
      }else{
         value = valueObj.toString();
      }
      returnMap.put(key, value);
   }
}

Guess you like

Origin blog.csdn.net/i929479824/article/details/91418242