更新时间:2023-02-15 15:49:24
@Override
public RibResource toResource(Rib rib) {
return createResourceWithId(rib.getId(), rib);
}
createResourceWithId()
在内部根据控制器的URL创建自我链接在你的情况下,包含占位符 {idInt}
所以你必须提供一个参数:
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());
更好的选择是不要调用 createResourceWithId( )
。只需将现有的所有内容( instantiateResource()
移至 toResource()
。
The better choice would be not to call createResourceWithId()
at all. Just move everything you now have in instantiateResource()
to toResource()
.