2
當我嘗試在java中使用spring獲取HttpMessageNotReadableException時,發生HttpMessageNotReadableException。 打印的堆棧跟蹤說:Spring HttpMessageNotReadableException
嵌套的異常是org.springframework.http.converter.HttpMessageNotReadableException:無法讀取JSON:非法字符((CTRL-CHAR,代碼31)):僅定期空白(\ r \ n,\ t)允許在令牌之間
它與我的獲取方式有關,或者與我的響應格式有關?
我打電話它的方式是:
HttpEntity<JSONObject> entity = new HttpEntity<JSONObject>();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("Accept", "application/x-gzip");
headers.set("charset", "UTF-8");
return getConnector().exchange(url, HttpMethod.GET, entity, JSONObject.class);
getConnector()返回一個RestConnector
的響應頭包括: 內容編碼:gzip 內容類型:應用程序/ JSON
我不知道它是否與編碼有關gzip
編輯: 問題是,內容編碼是gzip..finally,我用HttpClient,它支持gzip編碼