2014-09-01 128 views
0

我想通过一个对象到另一个类使用春天(我不知道我使用正确的术语,我很新)这样说:春天错误 - springframework.web.client.HttpClientErrorException:404没有找到

TestServicesUtils.getTemplate().postForLocation(
    "http://" 
    + serverConfig 
    + ":" 
    + port 
    + "/test/rest/TestResultService/insertTestResult/", 
    results); 

当我运行它得到该行的程序,它trows的Exception

log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient). 
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 
org.springframework.web.client.HttpClientErrorException: 404 Not Found 
     at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76) 

了试图连接到班级:

@Service("TestRestImpl") 
@Path("TestResultService") 
@Produces("application/json") 
public class TesttRestImpl implements TestResultRest 
{ 
    ... 
    @POST 
    @Override 
    @Path("/insertTestResult") 
    @Consumes("application/xml") 
    public void insertTestResult(TestRestCollection list) { 
     testresultservicedao.insertTestResult(list.getListOfResults()); 
    } 
} 

路径似乎很好,我不知道为什么找不到方法。我需要注册路径吗?

+0

你能告诉我们你的* web.xml *文件吗? – tmarwen 2014-09-02 09:13:12

回答

3

您的路径不正确。如果你有一个正确的路径,仍然有错误,那么是一个映射错误。 但在这种情况下,您有404错误,这意味着路径不存在。如果再有一个错误,你必须注册,以映射的conf路径中@Path("/test/rest/TestResultService/insertTestResult/")

然后:

你的路径更改为。

+0

我不知道我需要将ref bean添加到application-context.xml – david 2014-09-02 15:22:26