简体   繁体   English

Spring HATEOAS-两个相同的链接

[英]Spring HATEOAS - two same links

lately I've been doing some projekt with Spring Data and Rest with HATEOAS. 最近我一直在使用Spring Data做项目,而在HATEOAS进行其他项目。

My question is, is it normal, that in entity links secion, I have 2 same links? 我的问题是,在实体链接部分中,我有2个相同的链接是否正常?

在此处输入图片说明

Here is repository: 这是存储库:

Repository 知识库

Yes it is. 是的。 But it's not always the case: the 'user' link is actually a templated link that gets enriched in certain cases. 但这并非总是如此:“用户”链接实际上是模板链接,在某些情况下会变得更加丰富。

For instance, should you define the following projection : 例如,您应该定义以下投影

@Projection(name = "summary", types = { User.class }) 
interface Summary { 

  String getUsername(); 
  String getEmail();

}

then the user link would show the projection parameter: 那么user链接将显示projection参数:

...
"_links" : {
  "self" : {
    "href" : "http://localhost:8080/users/1"
  },
  "user" : {
    "href" : "http://localhost:8080/users/1{?projection}"
    "templated" : true
  }

And you could be able to get a summary of user 1 by GETting http://localhost:8080/users/1?projection=summary . 您可以通过获取http://localhost:8080/users/1?projection=summary来获得用户1的http://localhost:8080/users/1?projection=summary

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM