修复请求form表单提交时,参数值被双引号括了起来

main
weilin.zhu 2023-01-05 12:14:38 +08:00
parent 4823cfe1a8
commit 4bbe6a2df8
1 changed files with 14 additions and 4 deletions

View File

@ -1003,14 +1003,20 @@ public class HttpUtils {
if (Strings.isNullOrEmpty(contentType)) {
List<NameValuePair> nvps = new ArrayList<>();
for (Map.Entry<String, Object> entry : params.entrySet()) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
//nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
//修复请求form表单提交时参数值被双引号括了起来
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
}
httpPost.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
List<NameValuePair> nvps = new ArrayList<>();
for (Map.Entry<String, Object> entry : params.entrySet()) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
//nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
//修复请求form表单提交时参数值被双引号括了起来
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
}
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
// } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
@ -1187,14 +1193,18 @@ public class HttpUtils {
if (Strings.isNullOrEmpty(contentType)) {
List<NameValuePair> nvps = new ArrayList<>();
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
//nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
//修复请求form表单提交时参数值被双引号括了起来
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
}
httpPut.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
List<NameValuePair> nvps = new ArrayList<>();
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
//nvps.add(new BasicNameValuePair(entry.getKey(), JSON.toJSONString(entry.getValue())));
//修复请求form表单提交时参数值被双引号括了起来
nvps.add(new BasicNameValuePair(entry.getKey(), Util.null2String(entry.getValue())));
}
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
} else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {