coding
kangyongh的gravatar頭像
kangyongh2019-09-30 10:38:07

springcloud進行遠程調用的時候,微服務返回的json數據報錯

在springcloud進行遠程調用的時候,微服務返回的json數據 ,但json里面的字段少的時候能正常返回,不限制條數。字段多的時候數據條數相同無法正常返回,報以下錯誤,那位大神能否幫忙解決一下

{
    "timestamp": "2019-09-30T02:25:14.187+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "Error while extracting response for type [class java.lang.Object] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\\r, \\n, \\t) is allowed between tokens; nested exception is com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\\r, \\n, \\t) is allowed between tokens\n at [Source: (com.sun.jersey.client.apache4.ApacheHttpClient4Handler$HttpClientResponseInputStream); line: 1, column: 2]",
    "path": "/customerList"
}

運行環境

jdk7+tomcat7+mysql+IntelliJ IDEA+maven

項目技術(必填)

Springcloud 中 RestTmplate遠程調用

相關代碼片段

private ResponseEntity<Object> request(ServletRequest req, String url, HttpMethod method, Map<String, Object> params) {
        HttpServletRequest request = (HttpServletRequest) req;
        //獲取header信息
        HttpHeaders requestHeaders = new HttpHeaders();
        Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()) {
          String key = (String) headerNames.nextElement();
          String value = request.getHeader(key);
          requestHeaders.add(key, value);
        }
        requestHeaders.remove("Content-Length");
        requestHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(convertPar(params),requestHeaders);
        ResponseEntity<Object> rss = restTemplate.exchange(url, method, requestEntity, Object.class, params);
        return rss;
    }

所有回答列表(0)
頂部客服微信二維碼底部
>掃描二維碼關注最代碼為好友掃描二維碼關注最代碼為好友
谁有北京pk10计划群