【发布时间】:2017-03-02 13:41:54
【问题描述】:
我的问题与这里 (Exposing link on collection entity in spring data REST) 提出的问题完全相同。但是该主题中的任何内容都无法帮助我将自定义链接添加到集合调用。
@Component
public class EventListResourceProcessor implements ResourceProcessor<Resources<Event>> {
@Autowired
private RepositoryEntityLinks entityLinks;
@Override
public Resources<Event> process(Resources<Event> events) {
events.add(entityLinks.linkToCollectionResource(Event.class).withRel("events"));
return events;
}
}
在这种情况下永远不会调用 process 方法。
我需要调用 http://localhost:8080/event 并在 _links 部分下使用 my_custom_link 获取以下 JSON:
{
"_embedded": {
"event": [
{
"id": "1",
"name": "Updated event"
}]
},
"_links": {
"self": {
"href": "http://localhost:8080/event"
},
"profile": {
"href": "http://localhost:8080/profile/event"
},
"my_custom_link": {
"href": "http://localhost:8080/custom/"
}
},
"page": {
"size": 20,
"totalElements": 4,
"totalPages": 1,
"number": 0
}
}
}
你能告诉我吗?
提前致谢!
【问题讨论】:
标签: rest spring-data-rest spring-hateoas