Commit ddbe93eb authored by 张永's avatar 张永

加方法

parent 769207c0
......@@ -275,6 +275,27 @@ public class HttpUtil {
}
return StringUtil.join("&", params);
}
public static String formatToQueryStringAndNull(Map<?, ?> parameters) {
List<String> params = new ArrayList<String>();
if (parameters != null) {
for (Object key : parameters.keySet()) {
Object val = parameters.get(key);
String sKey = String.valueOf(key);
Object[] sVals = (val == null ? null : (val instanceof Object[] ? (Object[]) val : (val instanceof Collection<?> ? ((Collection<?>)val).toArray() : new Object[] { val })));
if (sVals != null && sVals.length > 0) {
for (Object sVal : sVals) {
if(StringUtil.isNotEmpty(sVal)) {
params.add(sKey + "=" +sVal);
}
}
} else {
params.add(sKey + "="); //空值 参与签名 字节跳动
}
}
}
return StringUtil.join("&", params);
}
public static String post(String requestUrl, Map<String, Object> parameters, Map<String, String> headers,
Map<String, File> attachments, String contentType) {
......
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