|
UI层调用sxcx报错:
把同样的代码放在main中就没有问题,错在哪?
public static void main(String[] args) {
String host = "http://jshmgsdmfb.market.alicloudapi.com";
String path = "/shouji/query";
String method = "GET";
Map<String, String> headers = new HashMap<String, String>();
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
headers.put("Authorization", "APPCODE 5f01998661424161bf86f92e468d2188");
Map<String, String> querys = new HashMap<String, String>();
querys.put("shouji", "13807122945");
try {
/**
* 重要提示如下:
* HttpUtils请从
* https://github.com/aliyun/api-ga ... util/HttpUtils.java
* 下载
*
* 相应的依赖请参照
* https://github.com/aliyun/api-ga ... blob/master/pom.xml
*/
HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
System.out.println(response.toString());
//获取response的body
System.out.println(EntityUtils.toString(response.getEntity()));
} catch (Exception e) {
e.printStackTrace();
}
}
public static void sxcx(String param_string){
System.out.println(param_string);
String host = "http://jshmgsdmfb.market.alicloudapi.com";
String path = "/shouji/query";
String method = "GET";
Map<String, String> headers = new HashMap<String, String>();
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
headers.put("Authorization", "APPCODE 5f01998661424161bf86f92e468d2188");
Map<String, String> querys = new HashMap<String, String>();
querys.put("shouji", "13807122745");
try {
/**
* 重要提示如下:
* HttpUtils请从
* https://github.com/aliyun/api-ga ... util/HttpUtils.java
* 下载
*
* 相应的依赖请参照
* https://github.com/aliyun/api-ga ... blob/master/pom.xml
*/
HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
System.out.println(response.toString());
//获取response的body
System.out.println(EntityUtils.toString(response.getEntity()));
} catch (Exception e) {
e.printStackTrace();
}
}
|
|