我有一個問題,我似乎無法自己弄清楚。特殊字符構成REST web服務通信問題
我想從Android應用程序發佈JSON對象到REST web服務。一切工作正常,直到我添加像å,ä,ö這樣的特殊字符。
JSONObject absenceObject = new JSONObject();
absenceObject.put(INFO_DESCRIPTION, "åka pendeltåg");
StringEntity entity = new StringEntity(absenceObject.toString());
httpPost.setEntity(entity);
httpPost.setHeader("Accept", "application/json";character);
httpPost.setHeader("Content-type", "application/json;charset=UTF-8");
HttpResponse response = httpclient.execute(httpPost);
如果我打印absenceObject.toString()並將結果複製到常規休息客戶端,它工作正常。
我非常感謝任何幫助!
非常感謝! – notBanana 2011-04-28 13:52:28
StringEntity entity = new StringEntity(body,「UTF-8」); //wr.writeBytes(entity.toString()); wr.writeUTF(entity.toString());我曾嘗試兩種方式,但沒有工作。提前致謝。 – 2016-04-13 06:04:08