我正在使用spring java中的resttemplate处理回调url,基本上,我试图在resttemplate中将@RequestBody作为字符串数据发送,它给了我一个404 not found错误,与我放置一些bean对象相比它给了我一个响应,但我想传递字符串数据而不是 bean 数据
需要解决的问题: 传递@RequestBody String bodydata 时出现404错误
@RequestMapping(path = "/EcAsynBasicFlowP2SIT", method = RequestMethod.POST, produces = MediaType.APPLICATION_XML_VALUE)
public String callBackSITP1(@RequestBody String bodydata) {
System.out.println("Body Data---->"+bodydata);
String response = restTemplate.postForObject("https://success.com/sit/callback", bodydata, String.class);
System.out.println("Response ----> "+response);
return response;
}
上面的代码给了我以下错误:
org.springframework.web.client.HttpClientErrorException$NotFound: 404 Not Found: [{ "httpCode":"404", "httpMessage":"Not Found", "moreInformation":"No resources match requested URI" }]
工作代码: 如果我将@RequestBody 作为bean 即@RequestBody EcAllFieldAsyn16P2Bean bodydata 传递,那么我会正确地得到我的响应
@RequestMapping(path = "/EcallField16P2SIT", method = RequestMethod.POST)
public String encryptDataOneWayP2SIT(@RequestBody EcAllFieldAsyn16P2Bean bodydata) {
String response = restTemplate.postForObject("https://success.com/sit/callback", bodydata, String.class);
return response;
}
请恢复解决方案。提前致谢。