【发布时间】:2015-03-18 19:02:06
【问题描述】:
我正在开发一个在码头 9.2.0 中运行的应用程序。 到目前为止效果很好。
现在我必须实现一个需要加载网页的功能。我正在使用此代码来加载它:
@Path( "/bla")
@GET
@Produces( MediaType.APPLICATION_JSON )
public ChildList getBla() {
ChildList childList = new ChildList();
String url = "http://www.google.de";
HttpGet httpGet = new HttpGet( url ) ;
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
try{
response = httpClient.execute( httpGet );
} catch ( Exception e ) {
e.printStackTrace();
}
return childList;
}
我收到“UnknownHostException”。
我尝试使用-Dhttp.proxyHost、-Dhttp.proxyPort、-Dhttp.proxyUser 和-Dhttp.proxyPassword 启动码头。我也尝试使用System.setProperty()在上述方法中设置这些属性。
然后我尝试在 Java 控制面板中设置代理设置。
但我仍然收到“UnknownHostException”。
还有其他方法可以解决这个问题吗?
【问题讨论】:
-
如果您尝试使用 ipaddress 会发生什么?
-
我也得到了 UnknownHostException。
-
在您的客户端/浏览器中,您设置代理了吗?
-
我正在使用 fiddler 2.4.8 来测试我的应用程序。没有配置代理,因为我调用的是localhost/myapplication/bla。