Spring HATEOAS Resource Assembler and Resource Links with many variables

烈酒焚心 提交于 2019-12-04 11:45:48
@Override
public RibResource toResource(Rib rib) {
    return createResourceWithId(rib.getId(), rib);
}

createResourceWithId() internally creates a self link based on the controller's URL. In your case that contains the placeholder {idInt} so you would have to provide a parameter for that:

CustomUserDetails user = CurrentUserUtils.getCurrentUser();
return createResourceWithId(rib.getId(), rib, user.getIdInt());

The better choice would be not to call createResourceWithId() at all. Just move everything you now have in instantiateResource() to toResource().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!