修复请求form表单提交时,参数值被双引号括了起来
parent
4823cfe1a8
commit
4bbe6a2df8
|
@ -1003,14 +1003,20 @@ public class HttpUtils {
|
||||||
if (Strings.isNullOrEmpty(contentType)) {
|
if (Strings.isNullOrEmpty(contentType)) {
|
||||||
List<NameValuePair> nvps = new ArrayList<>();
|
List<NameValuePair> nvps = new ArrayList<>();
|
||||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
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.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
|
||||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
||||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
|
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
|
||||||
List<NameValuePair> nvps = new ArrayList<>();
|
List<NameValuePair> nvps = new ArrayList<>();
|
||||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
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));
|
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
|
||||||
// } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
// } else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
||||||
|
@ -1187,14 +1193,18 @@ public class HttpUtils {
|
||||||
if (Strings.isNullOrEmpty(contentType)) {
|
if (Strings.isNullOrEmpty(contentType)) {
|
||||||
List<NameValuePair> nvps = new ArrayList<>();
|
List<NameValuePair> nvps = new ArrayList<>();
|
||||||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
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.setHeader("Content-Type", HttpArgsType.DEFAULT_CONTENT_TYPE);
|
||||||
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
||||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
|
} else if (contentType.toUpperCase().startsWith(HttpArgsType.X_WWW_FORM_URLENCODED.toUpperCase())) {
|
||||||
List<NameValuePair> nvps = new ArrayList<>();
|
List<NameValuePair> nvps = new ArrayList<>();
|
||||||
for (Map.Entry<String, Object> entry : paramsMap.entrySet()) {
|
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));
|
httpPut.setEntity(new UrlEncodedFormEntity(nvps));
|
||||||
} else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
} else if (contentType.toUpperCase().startsWith(HttpArgsType.APPLICATION_JSON.toUpperCase())) {
|
||||||
|
|
Loading…
Reference in New Issue