【发布时间】:2019-01-03 16:29:59
【问题描述】:
我有一个带有方法的控制器,它返回PagedResource,它看起来像这样:
@RequestMapping(value = "search/within", method = RequestMethod.POST)
public @ResponseBody PagedResources within(@RequestBody GeoJsonBody body,
Pageable pageable, PersistentEntityResourceAssembler asm) {
// GET PAGE
return pagedResourcesAssembler.toResource(page, asm);
}
现在,我想将该方法添加为根资源的链接,因此我执行以下操作:
public RepositoryLinksResource process(RepositoryLinksResource repositoryLinksResource) {
repositoryLinksResource.add(linkTo(methodOn(ShipController.class).within(null, null, null)).withRel("within"));
return repositoryLinksResource;
}
哪个有效,我得到了我的链接,但是它添加了没有分页参数的链接。所以它看起来像这样:
"within": {
"href": "http://127.0.0.1:5000/search/within"
},
我想把它变成:
"within": {
"href": "http://127.0.0.1:5000/search/within{?page, size}"
},
This 上一个关于 stackoverflow 的问题表明,在修复 corresponding issue on GitHub 后,它应该默认工作,但是它没有。
我做错了什么?
【问题讨论】:
标签: java spring spring-boot spring-data-rest spring-hateoas