网络是否开启了? 在手机浏览器里面试试。
用httpclient post 获取数据 是完全可以的,没什么奥秘。

解决方案 »

  1.   

    开启了,get 没问题 就post 不行,
    手机浏览器里面用 js也可以
      

  2.   

    public byte[] httpPost(String urlStr, String content){
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(urlStr);
    try{
    StringEntity sn = new StringEntity(content);
    httppost.setEntity(sn);
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity entity = response.getEntity(); InputStream instream = entity.getContent();
    byte[] buf = new byte[(int) entity.getContentLength()];
    instream.read(buf);

    return buf;
    }catch(Exception e){
    e.printStackTrace();
    }
    return null;
    }
      

  3.   


    不行的,不清楚是不是传的参数不对,
    我要传过去的是个json格式的参数 
      

  4.   

    500是server端问题,你用java吧,js这种不稳定
      

  5.   

    String content 格式是什么样的
    一般是 key=字符串 这个字符串urlEncoder一下
      

  6.   

    服务器端用 .net的 webapi 写的,用js的get post 没问题,用C#的get post 也没问题
    唯独用android 的post的出问题, get也问题.
      

  7.   


    function post() {
    $.post(hostad+'/api/Feedback', 
    { "name": "32", "title": "就是测试", "content": "就是测试1" },  //参数
    function (data) { $("span").text(data.result);}, "json")
    .success(function () { alert("second success"); })
    .error(function (e) { alert("error" ); 
    });
     }js 是这样的
    服务端执行结果
      

  8.   

    Java里面怎么写的? 打印日志 瞧瞧,你现在是java里面没调用成功 ?
      

  9.   


    public String httpPost(String baseUrl, List<BasicNameValuePair> params) {
    String result = "";
    try {
    HttpClient httpClient = new DefaultHttpClient();
    HttpPost postMethod = new HttpPost(baseUrl);
    postMethod.setEntity(new UrlEncodedFormEntity(params, "utf-8")); 
    HttpResponse response = httpClient.execute(postMethod); // 执行POST方法
    int code = response.getStatusLine().getStatusCode(); // 获取响应码
    if (code == 200) {
    result = EntityUtils.toString(response.getEntity(), "utf-8"); // 获取响应内容
    } } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
    } catch (ClientProtocolException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    } catch (Exception e) {
    }
    return result;
    } public JSONObject httpPostJson(String baseUrl,
    List<BasicNameValuePair> params) {
    String src = httpPost(baseUrl, params);
    JSONObject result = null;
    if (!"".equals(src)) {
    try {
    result = new JSONObject(src);
    } catch (JSONException e) {
    e.printStackTrace();
    }
    }
    return result;
    } public JSONObject httpPostJson(String baseUrl, JSONObject params)
    throws ClientProtocolException, IOException, JSONException {
    JSONObject result = null;
    HttpPost request = new HttpPost(baseUrl);
    NavType.LOG("httpPostJson:" + baseUrl + "?" + params.toString());
    StringEntity se = new StringEntity(params.toString());
    request.setEntity(se);
    HttpResponse httpResponse = new DefaultHttpClient().execute(request);
    int code = httpResponse.getStatusLine().getStatusCode();
    NavType.LOG("httpPostJson:"+code);
    if (code == 200) {
    String retSrc = EntityUtils.toString(httpResponse.getEntity());
    result = new JSONObject(retSrc);
    }
    return result;
    }
    安卓的用2种方式都执行不成功
      

  10.   

    02-26 11:46:53.574: E/---NavType---(26780): httpPostJson:http://192.168.10.244:8088/api/Feedback/?{"content":"考虑考虑","title":"look","name":"18"}
    02-26 11:46:53.706: E/---NavType---(26780): httpPostJson:500
    02-26 11:46:53.716: E/---NavType---(26780): httpPostJson:{"Message":"发生错误。"}对应输出日志方法
    NavType.LOG("httpPostJson:" + baseUrl + "?" + params.toString());
    NavType.LOG("httpPostJson:"+code);
    NavType.LOG("httpPostJson:"+EntityUtils.toString(httpResponse.getEntity()));问题是服务器也没报错,android这边也没报错,
    应该是iis上报的错,我不清楚在哪看iis上的错误.
      

  11.   

    我现在改成用 js java交互的方式 来post表单了,虽然绕了一个弯,但是能行