关于httpclient的https问题

龙飞tgbmlp 2012-10-26 09:11:03
请教一个问题
使用HttpsURLConnection这个类可以直接访问https的网站,也不需要证书
private void testIt1(){
URL url;
try {
url = new URL("https://www.alipay.com/index.html");
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
//dump all the content
if(con!=null){
System.out.println("****** Content of the URL ********");
BufferedReader br =new BufferedReader(new InputStreamReader(con.getInputStream()));
String input;
while ((input = br.readLine()) != null){
System.out.println(input);
}
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}

换成httpclient怎么写
例如:我打开支付宝,在浏览器里输入网址即可,换成httpclient怎么写??
谢谢!
...全文
141 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
龙飞tgbmlp 2012-10-26
  • 打赏
  • 举报
回复
对了,我看网上 httpclient 访问https,都需要先导入一个密钥证书,为什么HttpsURLConnection类不需要呢?

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧