Commit cd2a8bb9 authored by Administrator's avatar Administrator

2022-11.24 解析ip地址异常处理

parent d09a4c4f
......@@ -175,11 +175,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
* 根据ip获取详细地址
*/
public static String getCityInfo(String ip) {
try {
if (ElAdminProperties.ipLocal) {
return getLocalCityInfo(ip);
} else {
return getHttpCityInfo(ip);
}
} catch (Exception e) {
return "解析失败";
}
}
/**
......@@ -187,6 +191,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
*/
public static String getHttpCityInfo(String ip) {
String api = String.format(ElAdminConstant.Url.IP_URL, ip);
System.out.println("api = " + api);
JSONObject object = JSONUtil.parseObj(HttpUtil.get(api));
return object.get("addr", String.class);
}
......
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