@RequestParam,也有@RequestBody 不能同时使用可以使用 HttpServletRequest 接收,有时间看下解析器,分析下源码
public Map<String, Object> commonHttpRequestParamConvert(HttpServletRequest httpServletRequest) {
Map<String, Object> result = new HashMap<>(16);
try {
Map<String, String[]> requestParams = httpServletRequest.getParameterMap();
if (requestParams != null && !requestParams.isEmpty()) {
requestParams.forEach((key, value) -> result.put(key, value[0]));
} else {
StringBuilder params = new StringBuilder();
try {
String str;
BufferedReader br = httpServletRequest.getReader();
while ((str = br.readLine()) != null) {
params.append(str);
}
} catch (Exception e) {
PublicUtils.printException(e);
}
if (params.length() > 0) {
JSONObject paramJsonObject = JSON.parseObject(params.toString());
if (paramJsonObject != null && !paramJsonObject.isEmpty()) {
paramJsonObject.forEach((key, value) -> result.put(key, value));
}
}
}
} catch (Exception e) {
System.out.println("commonHttpRequestParamConvert error, cause : " + e);
}
return result;
}