问题
lately I've been doing some projekt with Spring Data and Rest with HATEOAS.
My question is, is it normal, that in entity links secion, I have 2 same links?
Here is repository:
Repository
回答1:
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:
...
"_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
.
来源:https://stackoverflow.com/questions/47649664/spring-hateoas-two-same-links