我有一个带有请求参数的方法,我正在尝试从另一个资源链接到这个方法。我希望链接是这样的:
"rel":{
"href":".../resources{?param}",
"templated":true
}
我尝试了以下但没有成功:
//First attempt
resources.add(linkTo(methodOn(Controller.class).method(null)).withRel("rel")
//Second attempt
resources.add(linkTo(methodOn(Controller.class).method("{parameter}")).withRel("rel")
//Third attempt
resources.add(entityLinks.linkToCollectionResource(LinkedResource.class).withRel("rel");
最佳答案
它现在可以工作了,您可以检查以下现已解决的问题 - https://github.com/spring-projects/spring-hateoas/issues/169 .
正如您在第一次尝试中提到的那样 -
resources.add(linkTo(methodOn(Controller.class).method(null)).withRel("rel")
应该管用。
关于spring-hateoas - 如何构建模板化链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29218817/