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;
}

posted on 2020-06-22 12:33  0o好好先生o0  阅读(2096)  评论(0编辑  收藏  举报

导航