Commit 3b0db1c1 authored by 张永's avatar 张永

1

parent 2fba11ca
......@@ -6,6 +6,10 @@ import java.net.URLDecoder;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest;
......@@ -40,6 +44,37 @@ public class ServletUtil {
}
}
public static Map<String, Object> getParameterMap(HttpServletRequest request) {
// 参数Map
Map<String, String[]> properties = request.getParameterMap();
// 返回值Map
Map<String, Object> returnMap = new HashMap<String, Object>();
Iterator<Entry<String, String[]>> entries = properties.entrySet().iterator();
Map.Entry<String, String[]> entry;
String name = "";
String value = "";
while (entries.hasNext()) {
entry = (Map.Entry<String, String[]>) entries.next();
name = (String) entry.getKey();
Object valueObj = entry.getValue();
if (null == valueObj) {
value = "";
} else if (valueObj instanceof String[]) {
String[] values = (String[]) valueObj;
for (int i = 0; i < values.length; i++) {
value = values[i] + ",";
}
value = value.substring(0, value.length() - 1);
} else {
value = valueObj.toString();
}
returnMap.put(name, value);
}
return returnMap;
}
/**
*
* @Description 读取传入的json字符
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment