- 使用get方法:
  String url="http://www.google.com/guestbook.jsp"?name=ox&id=100;
 HttpClient client = new DefaultHttpClient();
 HttpGet request = new HttpGet(url);
- 使用post方法
 String url="http://www.google.com/guestbook.jsp";
 HttpClient client = new DefaultHttpClient();
 HttpPost request = new HttpPost(url);
  List pair=new ArrayList();  
  pair.add(new BasicNameValuePair("name","ox"));
  pair.add(new BasicNameValuePair("id","100"));
   try 
 {
  request.setEntity(new UrlEncodedFormEntity(pair)); 
  } catch (UnsupportedEncodingException e) {    // TODO Auto-generated catch block    e.printStackTrace();   }
 
沒有留言:
張貼留言