java 通过request.getParameterMap()获取前台传入参数

public Map<String, Object> getData(HttpServletRequest request) throws Exception{
Map<String,Object> map = new HashMap<String, Object>();
Map<String, String[]> mapData = request.getParameterMap();
Iterator it = mapData.keySet().iterator();
while (it.hasNext()){
Map.Entry<String, String[]> entry = (Map.Entry<String, String[]>) it.next();
for (String v: entry.getValue())
map.put(entry.getKey(), this.isEmpty(v)?null:v);
}
return map;
}


public boolean isEmpty(String str) {
boolean bool = false;
if( str == null || str.isEmpty() || "".equals(str)) {
bool = true;
}
return bool;
}
原文地址:https://www.cnblogs.com/lt3232696/p/13176216.html