여기에 게시 된 답변과 Google에 게시 된 답변을 살펴본 결과 왜이 오류가 발생하는지 혼란 스럽습니다. 내가 만든 json 변수는 내가 권한이 없다고 읽습니다. 모두 허용하도록 권한을 변경했는데 오류가 해결되지 않았습니다. 또한 196의 컴퓨터 IP 주소와 127.0.0.1의 온라인 예를 사용하여 URL을 가지고 놀았습니다. 내 IP를 사용할 때 위의 오류가 발생합니다. 내가 127.0을 사용했을 때 나는 IP 주소가 아무데도 가지 않기 때문에 내가 추측하는 오류를 연결하는데 실패했다. 내 PHP 코드를 테스트하고 MySQL DB에 데이터를 입력했습니다. 그래서 내 문제는 내 자바 코드에 있음을 압니다. 아래 코드를 게시하고 최소한의 코드를 게시하려고하므로 코드 덤프를 수행합니다. 더 많은 코드를 게시하고 싶다면 알려주십시오.데이터를 파싱하는 중 오류가 계속 발생했습니다. org.json.JsonException : 값 <! DOCTYPE
try {
// check for request method
if(method.equals("POST")){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}else if(method.equals("GET")){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
그래서 권한을 얻으려면 무엇을해야합니까?
내가
catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
을 위해 무엇입니까 오류 메시지는 다음과 같습니다 당신이 웹 서버를 실행해야 가능성이없는 어디
Error parsing data org.json.JSONException: Value DOCTYPE of type java.lang.String cannot be converted to JSONObject
오류를 해결하는 방법은 서버 스크립트 출력을 확인하십시오. 브라우저에서 또는 테스트 장치에 액세스하여 오류가 발생했는지 확인하십시오. – kabuto178
브라우저에서 스크립트를 실행할 때 오류가 표시되지 않았습니다. – Aaron
int = httpResponse.getStatusLine(). getStatusCode();를 사용하면이 코드를 실행하는 동안 방화벽을 비활성화하려고 시도 했습니까? 403 – Aaron