【发布时间】:2018-01-22 17:46:44
【问题描述】:
根据this 规范,以 hal+json 格式公开数据的应用程序应在 _links json 字段中提供嵌入式链接。但是,如果我像这样在 spring-data 1.5.9 中声明我的 REST 存储库:
@RepositoryRestResource(path = "storage-node", excerptProjection = IBrief.class)
public interface IStorageNodeRepository extends JpaRepository<StorageNode, Long> {
@Query("FROM StorageNode sn WHERE sn.parent is null order by sn.uploadTs ASC")
List<StorageNode> findAllRootNodes();
}
我得到以下 json:
{
"nodeType" : "Image",
"text" : "100.jpeg",
"uploadTs" : "2018-01-11T23:48:25.724Z",
/* ... Irrelevant ... */
"links" : [ {
"rel" : "self",
"href" : "http://localhost:8080/emerald/api/hal/storage-node/31"
}
/* ... Irrelevant ... */
}
正如我们所见,它在“链接”字段中导出链接,没有前导下划线。是否需要额外配置才能按照 HAL 规范导出数据?
【问题讨论】:
标签: spring-data hateoas spring-hateoas