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(), ToolUtil.isEmpty(v)?null:v);
}
return map;
}

猜你喜欢

转载自www.cnblogs.com/lt3232696/p/13176216.html