-2

这是我读取 Web 应用程序发送到 android 的 json 对象的代码

InputStream instream = entity.getContent();

    String result = "";
    try {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(instream, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line1 = null;
        while ((line1 = reader.readLine()) != null) {
            sb.append(line1 + "\n");
        }
        instream.close();
        result = sb.toString();
        Log.i("xxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxx");
        Log.i("Read from server", result);
        Log.i("xxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxx");

    } catch (Exception e) {
        Log.e("log_tag", "Error converting result " + e.toString());
    }

    // try parse the string to a JSON object
    try {
        JSONObject jArray = new JSONObject(result);
    }

    catch (JSONException e) {
        Log.e("log_tag", "Error parsing data " + e.toString());
    }

} catch (Exception e) {
    Log.i("------resultat---------", "Errrrrrrrrrrrooooooor");
}

但是在 Logcat 中显示结果时它不显示

当在代码android中执行这一行时

                   Log.i("xxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxx");
      Log.i("Read from server", result);
      Log.i("xxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxx");

它显示此代码

04-12 09:39:59.980:  xxxxxxxxxxxxxxxxxxxxxx
04-12 09:39:59.980: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
04-12 09:39:59.980:  <html><head>
04-12 09:39:59.980:  <title>403 Forbidden</title>
04-12 09:39:59.980:  </head><body>
04-12 09:39:59.980:  <h1>Forbidden</h1>
04-12 09:39:59.980:  <p>**You don't have permission to access /younes_project/younesservices.php**
04-12 09:39:59.980:  on this server.</p>
04-12 09:39:59.980:  </body></html>
04-12 09:39:59.980: xxxxxxxxxxxxxxxxxxxxxx

请问这种情况有什么问题:):):)

4

1 回答 1

0

这不是您的代码的问题。这是服务器端脚本(PHP)或文件访问权限的问题。服务器正在向您发送错误页面,而不是 json 响应。您可以联系您的 PHP 开发人员要求他更改文件访问权限文件 /younes_project/younesservices.php。

于 2013-04-12T10:00:40.147 回答