Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在SpringJava中使用resttemplate在回调URL中将@RequestBody作为字符串传递_Java_Spring_Restapi_Spring Resttemplate - Fatal编程技术网

如何在SpringJava中使用resttemplate在回调URL中将@RequestBody作为字符串传递

如何在SpringJava中使用resttemplate在回调URL中将@RequestBody作为字符串传递,java,spring,restapi,spring-resttemplate,Java,Spring,Restapi,Spring Resttemplate,我在SpringJava中使用resttemplate处理回调url,基本上,我试图在resttemplate中以字符串数据的形式发送@RequestBody,它会给我一个404NotFound错误,相比之下,如果我放置一些bean对象,它会给我一个响应,但我希望传递字符串数据而不是bean数据 需要解决的问题: 当传递@RequestBody字符串bodydata时,它给我404错误 @RequestMapping(path = "/EcAsynBasicFlowP2SIT"

我在SpringJava中使用resttemplate处理回调url,基本上,我试图在resttemplate中以字符串数据的形式发送@RequestBody,它会给我一个404NotFound错误,相比之下,如果我放置一些bean对象,它会给我一个响应,但我希望传递字符串数据而不是bean数据

需要解决的问题: 当传递@RequestBody字符串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;
    }
请回复解决方案。提前谢谢