【发布时间】:2011-10-06 10:22:57
【问题描述】:
我正在尝试以查询字符串的格式(例如:url?values)向服务器发送 http 请求,并在我的 android 设备上获得响应。
但是HttpPost httppost = new HttpPost(URL); 正在抛出异常。
注意:我只能以这种格式发送,否则请告知服务器程序员如何读取请求的 php 代码:
HttpPost httppost = new HttpPost(URL);
JSONObject json = new JSONObject();
try {
// JSON data:
json.put("PN", "Products");
json.put("position", "5th");
JSONArray postjson=new JSONArray();
postjson.put(json);
// Post the data:
httppost.setHeader("json",json.toString());
HttpParams ht=httppost.getParams().setParameter("jsonpost",postjson);
String s=ht.toString();
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
【问题讨论】:
-
抛出了什么异常?
-
抛出异常invokespecial java.lang.RuntimeException(java.lang.String)
-
也是一个错误/AndroidRuntime(8647):at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
-
如果您可以将整个堆栈跟踪添加到您的问题中会有所帮助。