k13*_*13i 4 java spring annotations spring-data spring-data-rest
我正在使用Spring Data REST。RepositoryRestResource注释具有两个不同的字段:path和collectionResourceRel。两者之间有什么区别?我无法通过阅读文档来解决这个问题。
path 描述如下:
此资源将导出到的路径段。
并collectionResourceRel描述为:
生成指向集合资源的链接时要使用的rel值。
在所有代码示例中,我都看到这两个属性相同。有什么不同的情况吗?它们之间的实际区别是什么?
例如,对于实体User,默认值为:
路径 =users
itemResourceRel =user
collectionResourceRel =users
例:
GET /用户 (路径:users)
"_links": {
"self": {
"href": "http://localhost:8080/api/users"
},
"users": { <-- collectionResourceRel
"href": "http://localhost:8080/api/users"
}
}
Run Code Online (Sandbox Code Playgroud)
GET /用户/ 1(路径:users)
"_links": {
"self": {
"href": "http://localhost:8080/api/users/1"
},
"user": { <-- itemResourceRel
"href": "http://localhost:8080/api/users/1"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1591 次 |
| 最近记录: |