我正在尝试使用将对象传递给另一个类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的路径。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)