对象的Spring RESTful服务URL
如何将URL()转换为域对象 我会让我的客户提交的网址作为外键,我必须以某种方式解决他们 例如,我想与作者1一起创建一本书对象的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注释
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
也许这个测试可以帮助。。。