restTemplate.postForObject org.springframework.web.client.HttpClientErrorException:404 Not Found

时间:2015-10-08 20:54:22

标签: spring rest

org.springframework.web.client.HttpClientErrorException: 404 Not Found

上述方法中的restTemplate.postForObject()行返回

protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback,
        ResponseExtractor<T> responseExtractor) throws RestClientException {

    Assert.notNull(url, "'url' must not be null");
    Assert.notNull(method, "'method' must not be null");
    ClientHttpResponse response = null;
    try {
        ClientHttpRequest request = createRequest(url, method);
        if (requestCallback != null) {
            requestCallback.doWithRequest(request);
        }
        response = request.execute();
        if (!getErrorHandler().hasError(response)) {
            logResponseStatus(method, url, response);
        }
        else {
            handleResponseError(method, url, response);
        }
        if (responseExtractor != null) {
            return responseExtractor.extractData(response);
        }
        else {
            return null;
        }
    }
    catch (IOException ex) {
        throw new ResourceAccessException("I/O error on " + method.name() +
                " request for \"" + url + "\":" + ex.getMessage(), ex);
    }
    finally {
        if (response != null) {
            response.close();
        }
    }
}

我已经在REST客户端测试了uri和头信息并收到了响应 - 所以我知道这是正确的URL。

我在调试模式下运行它,并在RestTemplate.doExecute

中抛出异常
{{1}}

关于发生了什么的任何想法?感谢。

0 个答案:

没有答案