Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.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
对象的Spring RESTful服务URL_Spring_Spring Data_Spring Restcontroller_Spring Rest - Fatal编程技术网

对象的Spring RESTful服务URL

对象的Spring RESTful服务URL,spring,spring-data,spring-restcontroller,spring-rest,Spring,Spring Data,Spring Restcontroller,Spring Rest,如何将URL()转换为域对象 我会让我的客户提交的网址作为外键,我必须以某种方式解决他们 例如,我想与作者1一起创建一本书 POST /books {"title":"Harry Potter", "author":"http://127.0.0.1:8080/authors/1" 我发现了一个名为UriToEntityConverter的类,听起来不错,但当然有0个教程或示例 我从@RestController为我的对象提供服务。您只需使用请求映射定义路径,并使用pathVariable注释

如何将URL()转换为域对象

我会让我的客户提交的网址作为外键,我必须以某种方式解决他们

例如,我想与作者1一起创建一本书

POST /books
{"title":"Harry Potter", "author":"http://127.0.0.1:8080/authors/1"
我发现了一个名为UriToEntityConverter的类,听起来不错,但当然有0个教程或示例


我从@RestController为我的对象提供服务。

您只需使用请求映射定义路径,并使用pathVariable注释存储变量即可

@RequestMapping(value="/authors/{id}", method=RequestMehtod.POST)
public RequestEntity<String> doSomething(@PathVariable("id") long id) //id will contain your id
@RequestMapping(value=“/authors/{id}”,method=RequestMehtod.POST)
public RequestEntity doSomething(@PathVariable(“id”)long id)//id将包含您的id
也许这个测试可以帮助。。。