日期:2014-05-17  浏览次数:20530 次

如何接受post过来的字符串~~~
本帖最后由 a176532_007 于 2013-03-11 15:24:45 编辑
对方用HTTP POST 到我这边的ASP.NET页面里面,我用REQUEST.FORM["mobiledata"] 形式收不到他的任何字符。 他那边应该没有问题。应该我这边接收的问题。

我写的接收代码就一句话
   string json1 = HttpUtility.UrlDecode( Request.Form["mobiledata"]);

他那边的POST 代码,应该是JAVA 的,参数变量是mobiledata。看下我应该用什么方法获取?
public static String doPost(JSONObject json,String method,String url) throws IOException, JSONException {
// String url = Constants.BASE_URL+method;
Log.d(Tag, "url is "+url);
HttpPost httpPost = new HttpPost(url);

List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
if (json != null) {
@SuppressWarnings("unchecked")
Iterator<String> iter = json.keys();
while (iter.hasNext()) {
String key = iter.next();
params.add(new BasicNameValuePair(key, json.getString(key)));
Log.d(Tag, "key is "+key+"   value is "+json.getString(key));
}
}
HttpEntity httpEntity = new UrlEncodedFormEntity(params,
Constants.UTF8);
httpPost.setEntity(httpEntity);
HttpClient httpClient = new DefaultHttpClient();

HttpResponse httpResponse = httpClient.execute(httpPost);
 HttpConnectionParams.setConnectionTimeout(httpPost.getParams(), 5000);
 HttpConnectionParams.setSoTimeout(httpPost.getParams(), 10000);
 Log.d(Tag, "状态码:“"+httpResponse.getStatusLine().getStatusCode());
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
return Constants.CONNECSUC;
}else {return Constants.CONNECTFAIL;
}
}

------解决方案--------------------
Request["mobiledata"] 或Request.QueryString["mobiledata"] 看看