Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.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
如何使用SpringRESTTemplate将json数据发送到PHP服务器_Php_Spring_Resttemplate - Fatal编程技术网

如何使用SpringRESTTemplate将json数据发送到PHP服务器

如何使用SpringRESTTemplate将json数据发送到PHP服务器,php,spring,resttemplate,Php,Spring,Resttemplate,我正在开发一个android应用程序,我使用SpringRestTemplate从PHP服务器获取数据并将数据发布到PHP服务器。我试图将数据发布到PHP服务器,但PHP服务器什么也没有得到。如何使用SpringRestTemplate将json数据发布到PHP服务器并从PHP服务器获取json 我自己解决了这个问题。我将FormHttpMessageConverter添加到RestTemplate,如下所示: RestTemplate RestTemplate=新RestTemplate();

我正在开发一个android应用程序,我使用SpringRestTemplate从PHP服务器获取数据并将数据发布到PHP服务器。我试图将数据发布到PHP服务器,但PHP服务器什么也没有得到。如何使用SpringRestTemplate将json数据发布到PHP服务器并从PHP服务器获取json

我自己解决了这个问题。我将FormHttpMessageConverter添加到RestTemplate,如下所示:

RestTemplate RestTemplate=新RestTemplate(); restemplate.getMessageConverters().add(新表单httpMessageConverter())

然后我可以将json数据发布到PHP服务器。我使用以下方法在PHP服务器中获取json数据:

$jsonData=$_POST['json']

MultiValueMap<String, ArrayList<persona>> parts = new LinkedMultiValueMap<>();

parts.add("json", aaper);    

restTemplate.postForLocation(url,parts);   
MultiValueMap parts=新链接的MultiValueMap();
添加(“json”,aaper);
restTemplate.postForLocation(url、部件);

使用php?春天有php的味道吗?我以前从没听说过这样的事。我的英语很差,所以犯了一个错误。我已经改正了。谢谢