【发布时间】:2014-05-02 04:12:02
【问题描述】:
假设我有两个应用程序,一个是管理人员的 Person 应用程序,另一个是管理 Pants 的 Pants 应用程序。在 Person 应用程序中,Domain 对象 Person 有一个 ListpantId,它引用来自 Pants 应用程序的一条裤子的 id。
我不确定如何使用 Spring Data Rest 对此进行建模,以便在我序列化人员时,我能够嵌入到外部 Pants 应用程序的裤子实例的链接。 [甚至让 /person/123/pants 返回那些外部裤子资源的列表]
寻找以下内容:
GET http://www.mydomain.com/personapp/person/123:
{
"name" : "bob",
"age": "30",
"_links" : {
"self" : {
"href" : "http://www.mydomain.com/personapp/person/123"
},
"pants" : {
"href" : "http://www.mydomain.com/pantsapp/pants/456"
"href" : "http://www.mydomain.com/pantsapp/pants/789"
}
}
【问题讨论】:
-
附带说明,有谁知道 Spring-Data-Rest 是否计划支持任何类型的声明性超链接?我可以想象在 Person 的 List
中添加了一些注释,例如 @Link("domain.com/pantsapp/pants{pantsId} 将允许这种行为
标签: spring rest spring-data hateoas spring-data-rest