我必須在類似這樣的URL發送數據:用郵寄方式發送數據URI
http://webservices.fecth.es/school/message/sendmessage/ID/myStringId/目的地/myStringDestination/味精/myMessage
我在字符串中有必要的數據,但不是通過post方法發送的,我測試過這段代碼但不起作用:
String postURL = "http://webservices.fecth.es/school/message/sendmessage/";
HttpPost post = new HttpPost(postURL);
List<NameValuePair> param = new ArrayList<NameValuePair>();
param.add(new BasicNameValuePair("id", myId));
param.add(new BasicNameValuePair("destination", myStringDestination));
param.add(new BasicNameValuePair("msg", myMessage));
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(param,HTTP.ISO_8859_1);
post.setEntity(ent);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
他們可以幫我解決我的問題嗎?
非常感謝
不追加它作爲一個PARAM。簡單地附加它的網址。 – 2013-02-28 14:32:24
Rajesh建議正確的評價... – 2013-02-28 14:32:44