gpt4 book ai didi

java - 从 android httpclient 程序访问 Servlet 时连接被拒绝?

转载 作者:行者123 更新时间:2023-11-30 02:54:08 25 4
gpt4 key购买 nike

当我从 android httpclient utils 访问 localhost servlet 时,我收到了 connection refused 错误。 servlet 运行良好,但出现错误。

这是代码:

String dmurl="http://127.0.0.1:9090/DataManagerProject/DMServlet";                                  
HttpClient httpClient = new DefaultHttpClient();
HttpGet hrtreq = new HttpGet(dmurl);
HttpResponse resp = httpClient.execute(hrtreq);
String output = EntityUtils.toString(resp.getEntity());

我遇到以下错误 org.apache.http.conn.httphostconnectexception connection to refused

最佳答案

如果您使用模拟器为本地服务器运行您的应用程序。提及本地 ip 为 10.0.2.2 并且必须为您的应用提供 Internet 权限

更多详情请引用此link .

此外,关闭您 PC 中的防火墙和所有防病毒应用程序

关于java - 从 android httpclient 程序访问 Servlet 时连接被拒绝?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23591096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com