本文介绍如何通过HttpClient进行https访问。
下载并导入httpClient
下载httpClient,并将jar包导入到项目中
创建SSLClient类
创建SSLClient类,继承DefaultHttpClient,负责创建SSL连接:
1 | public class SSLClient extends DefaultHttpClient{ |
Get请求
1 | public static String doGet(String url, String params){ |
Post请求
1 | public static String doPost(String url, Map<String,String> params){ |
获取Cookie
1 | cookies = ((AbstractHttpClient) httpClient).getCookieStore().getCookies(); |