在java中的HttpClient [英] HttpClient in java

查看:94
本文介绍了在java中的HttpClient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用一个简单的HttpClient。

I want to use a simple HttpClient.

然而,看起来sun.net.www.http.HttpClient是无法访问的。

However, it appears sun.net.www.http.HttpClient is unaccessible.

另外,com.ibm.ws.http.HTTPConnection - 似乎更支持http服务器而不是客户端。为什么?因为当我创建一个HttpConnection实例时,它有一个我应该写的getHttpResponse。

Also, com.ibm.ws.http.HTTPConnection - appears to be more supporting of http server and not client. Why? because when I create an instance of HttpConnection, it has a "getHttpResponse" to which I am supposed to write.

无论如何使用IBM HttpConnection for HttpClient?

Anyway to use the IBM HttpConnection for HttpClient?

或者,我可以使用任何标准的httpClient代码吗?

Or, is there any standard httpClient code that I can use?

谢谢。

推荐答案

很多人使用 Apache的HTTPClient

查看它的教程,看看它是不是你想要的。

Have a look at the first few chapters of its tutorial to see if it's what you're looking for.

如果你已经在Java中构建了一些简单的东西,你可以看看 HttpURLConnection ,可用于构建HTTP请求(example )。但是,如果您需要做的不仅仅是简单的HTTP请求,那么HTTPClient可能就是这样。

If you're after something simple that's already built into Java, you can look at HttpURLConnection, which you can use to build HTTP requests (example). If you need to do anything more than just simple HTTP requests, though, HTTPClient is probably the way to go.

这篇关于在java中的HttpClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆