Browse Source

修复bug:HttpUtil中map转SwMap失败

4.0
FLYPHT 2 years ago
parent
commit
2d7cd82bca
1 changed files with 24 additions and 4 deletions
  1. +24
    -4
      smtweb-framework/core/src/main/java/cc/smtweb/framework/core/util/HttpUtil.java

+ 24
- 4
smtweb-framework/core/src/main/java/cc/smtweb/framework/core/util/HttpUtil.java View File

@@ -107,7 +107,12 @@ public class HttpUtil {
public static SwMap post(String url, Map<String, String> paras) throws Exception { public static SwMap post(String url, Map<String, String> paras) throws Exception {
String json_resp = post(url, null, paras, null); String json_resp = post(url, null, paras, null);
if (StringUtils.isEmpty(json_resp) || !json_resp.startsWith("{")) return null; if (StringUtils.isEmpty(json_resp) || !json_resp.startsWith("{")) return null;
return (SwMap) JsonUtil.parseMap(json_resp);
SwMap swMap = new SwMap();
Map map = JsonUtil.parseMap(json_resp);
if(map!=null){
swMap.putAll(map);
}
return swMap;
} }


/** /**
@@ -147,7 +152,12 @@ public class HttpUtil {
json_resp = new String(Base64.decodeBase64(json_resp), charset); json_resp = new String(Base64.decodeBase64(json_resp), charset);
} }
if (StringUtils.isEmpty(json_resp) || !json_resp.startsWith("{")) return null; if (StringUtils.isEmpty(json_resp) || !json_resp.startsWith("{")) return null;
return (SwMap) JsonUtil.parseMap(json_resp);
SwMap swMap = new SwMap();
Map map = JsonUtil.parseMap(json_resp);
if(map!=null){
swMap.putAll(map);
}
return swMap;
} }


/** /**
@@ -169,14 +179,24 @@ public class HttpUtil {
json_resp = new String(Base64.decodeBase64(json_resp), charset); json_resp = new String(Base64.decodeBase64(json_resp), charset);
} }
if (StringUtils.isEmpty(json_resp) || !json_resp.startsWith("{")) return null; if (StringUtils.isEmpty(json_resp) || !json_resp.startsWith("{")) return null;
return (SwMap) JsonUtil.parseMap(json_resp);
SwMap swMap = new SwMap();
Map map = JsonUtil.parseMap(json_resp);
if(map!=null){
swMap.putAll(map);
}
return swMap;
} }




public static SwMap post(String url, Map<String, String> header, Map<String, String> paras) throws Exception { public static SwMap post(String url, Map<String, String> header, Map<String, String> paras) throws Exception {
String json_resp = post(url, header, paras, null); String json_resp = post(url, header, paras, null);
if (StringUtils.isEmpty(json_resp) || !json_resp.startsWith("{")) return null; if (StringUtils.isEmpty(json_resp) || !json_resp.startsWith("{")) return null;
return (SwMap) JsonUtil.parseMap(json_resp);
SwMap swMap = new SwMap();
Map map = JsonUtil.parseMap(json_resp);
if(map!=null){
swMap.putAll(map);
}
return swMap;
} }


/** /**


Loading…
Cancel
Save