码迷,mamicode.com
首页 > 其他好文 > 详细

站立会议总结03

时间:2015-05-14 23:44:41      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

验证网上的获取网页post和cookice的JAVA代码,

 

 
List<Cookie> cookies;                      //保存获取的cookie  
HttpClient client = new DefaultHttpClient();                   
HttpResponse httpResponse;     
       
[java] view
plaincopy
String uriAPI = "http://210.43.188.41/_data/index_LOGIN.aspx";  
[java] view
plaincopy
/* 建立HTTP Post连线 */  
HttpPost httpRequest = new HttpPost(uriAPI);  
List<NameValuePair> params = new ArrayList<NameValuePair>();  
[java] view
plaincopy
  
params.add(new BasicNameValuePair("PassWord", "*****");   //这里的密码我用*取代了  
params.add(new BasicNameValuePair("UserID", "201150080223");    //这是学号  
params.add(new BasicNameValuePair("Sel_Type", "STU"));    //以学生身份登录  
[java] view
plaincopy
try {  
    // 发出HTTP request  
    httpRequest.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));  
    // 取得HTTP response  
    httpResponse = client.execute(httpRequest);   //执行  
    // 若状态码为200 ok  
    if (httpResponse.getStatusLine().getStatusCode() == 200) {   //返回值正常  
        // 获取返回的cookie  
        cookies = ((AbstractHttpClient) client).getCookieStore().getCookies();  
    } else {  
    }  
} catch (Exception e) {  
    e.printStackTrace();  
}  

  

站立会议总结03

标签:

原文地址:http://www.cnblogs.com/helloalbert/p/4504701.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!