HttpClient httpclient = new DefaultHttpClient();
//设置代理服务器
HttpHost proxy = new HttpHost(Config.getProxyHost(), Config.getProxyHostPort());
//将代理服务器信息添加的httpclient httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
HttpPost httppost = new HttpPost(Config.getLoginUrl());
//建立参数列表
List<NameValuePair> params = new ArrayList<NameValuePair>();
//开始添加参数
params.add(new BasicNameValuePair("username",Config.getLoginName()));
params.add(new BasicNameValuePair("password",Config.getPassword()));
HttpResponse response = null;
HeaderElement element = null;
try {
//将参数进行编码
uefEntity = new UrlEncodedFormEntity(params, "UTF-8");
//将参数添加的POST请求中
httppost.setEntity(uefEntity);
response = httpclient.execute(httppost);
Header header = response.getLastHeader("Set-Cookie");
element = header.getElements()[0];
} catch (ClientProtocolException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
} finally {
httpclient.getConnectionManager().shutdown();
}