JSON-Antwort zurück, die als text

Habe ich komponiert JSON-Antwort, wie unten in meinem java-servlet, wo JObject ist das JSON-Objekt erstellt

response.setContentType("application/json; charset=UTF-8");
PrintWriter printout = response.getWriter();
printout.print(JObject);
printout.flush();

Aber es bekam erhalten als text/plain im empfangenden Seite

[Server: Apache-Coyote/1.1, ETag: W/"XXXXXXXXXX", Last-Modified: Tue, 04 Jun 2013 10:42:31 GMT, Content-Type: text/plain, Content-Length: 2573, Date: Tue, 04 Jun 2013 10:44:01 GMT]

Wie man die genaue JSON-response?
Wenn ich komponiere die JSON Antwort in derselben Maschine, im immer JSON-Daten. Aber wenn ich komponiere die JSON Antwort in einem anderen server, dessen Rückkehr als text/plain.

- Und dies ist die JObject:

JSONObject JObject = new JSONObject(); 
JObject.put("Response", "1"); 
JObject.put("Message", "Client unauthorized"); 
Reden wir über Servlets?
JSON IST ein text, Sie zu analysieren, ist der zurückgegebene Wert.
Bieten JObject details... Erklärung & Initialisierung
JSONObject JObject = new JSONObject(); JObject.put("Response", "1"); JObject.put("Nachricht", "Kunde unauthorized");
Versuchen Sie response.setContentType("application/json"); ohne die char-Typ.

InformationsquelleAutor John | 2013-06-04

Schreibe einen Kommentar