// 从页面获取数据
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);
}
}
SpringMVC 获取参数map
最新推荐文章于 2022-03-11 23:56:42 发布