Java converts request data into map data

ublic static Map<String, Object> handleParamToMap(
HttpServletRequest request) {
Map<String, Object> map = new HashMap<>();
for (Entry<String, String[]> entry : request.getParameterMap()
.entrySet() ) {//Traverse the request parameter
String[] arr = entry.getValue();//Get the value of the request parameter (array)
String result = "";
if (null != arr && arr.length > 0) {
for ( int i = 0; i < arr.length; i++) {
result += arr[i];
if (i < arr.length - 1) {
result += ",";//There are multiple values ​​separated by commas
}
}
map.put(entry.getKey(), result);//Assign value to Map
}
}
return map;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326057395&siteId=291194637