我正在尝试使用Spring将对象传递给另一个类(我不确定我使用的是正确的术语,我对Spring还是很陌生的),方法是:
TestServicesUtils.getTemplate().postForLocation(
"http://"
+ serverConfig
+ ":"
+ port
+ "/test/rest/TestResultService/insertTestResult/",
results);
当我运行程序时,它到达该行并抛出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());
}
}
路径似乎很好,我不知道为什么找不到该方法。我需要注册路径吗?
您的路径不正确。如果您有正确的路径,但仍然出现错误,则是映射错误。但是在这种情况下,您会遇到404错误,这意味着该路径不存在。
将路径更改为: @Path("/test/rest/TestResultService/insertTestResult/")
然后,如果再次出错,则必须注册映射conf的路径。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句