小编caf*_*anu的帖子

在HttpResponse execute for android中,主机名可能不为null

我收到错误"目标主机不能为空,或在参数中设置".

  • I DO具有Internet权限在我的清单文件
  • 我把"http://"放在我的网址之前
  • 我会对 URL进行编码

这是我的代码:

   String url = "http://maps.google.com/maps/api/directions/json?origin=1600 Pennsylvania Avenue NW, Washington, DC 20500&destination=1029 Vermont Ave NW, Washington, DC 20005&sensor=false";
   HttpClient httpclient = new DefaultHttpClient();
   String goodURL = convertURL(url);//change weird characters for %etc
   HttpPost httppost = new HttpPost(goodURL);
   HttpResponse response = httpclient.execute(httppost);
Run Code Online (Sandbox Code Playgroud)

在第5行(上面的最后一行),我的程序抛出异常.这是确切的错误:

java.lang.IllegalArgumentException: Host name may not be null
Run Code Online (Sandbox Code Playgroud)

我在方法convertURL中编码我的字符串...

goodURL = http://maps.google.com/maps/api/directions/json?origin=3%20Cedar%20Ave%2c%20Highland%20Park%2c%20NJ%2008904&destination=604%20Bartholomew%20Road%2c%20Piscataway%2c%20New%20Jersey%2008854&sensor=false

有什么建议?谢谢!

android httpresponse http-post illegalargumentexception

10
推荐指数
1
解决办法
3万
查看次数

React - 基于浏览器的差异加载(es5、es6、esnext 等)

我来自角世界。Angular 8 最近发布了一个差异加载功能。这意味着,根据您的浏览器,将提供不同的编译 Javascript 代码。因此,假设您使用的是 Internet Explorer 11,该应用程序将下载 ES5 javascript 文件,而如果您使用的是常绿/新浏览器(chrome、firefox 等),那么您提供的 Javascript 将是 ES6。

看到这个(https://blog.angular.io/version-8-of-angular-smaller-bundles-cli-apis-and-alignment-with-the-ecosystem-af0261112a27

React 世界中有这样的事情吗?

javascript ecmascript-5 ecmascript-6 reactjs angular

5
推荐指数
1
解决办法
485
查看次数