【发布时间】:2015-01-01 15:12:12
【问题描述】:
我正在使用 spring data rest web mvc 2.2.1.RELEASE。 我期待以下格式
{
"content": [ {
"price": 499.00,
"description": "Apple tablet device",
"name": "iPad",
"links": [ {
"rel": "self",
"href": "http://localhost:8080/product/1"
} ],
"attributes": {
"connector": "socket"
}
}, {
"price": 49.00,
"description": "Dock for iPhone/iPad",
"name": "Dock",
"links": [ {
"rel": "self",
"href": "http://localhost:8080/product/3"
} ],
"attributes": {
"connector": "plug"
}
} ],
"links": [ {
"rel": "product.search",
"href": "http://localhost:8080/product/search"
} ]
}
但我得到这样的输出:
{
"_links" : {
"self" : {
"href" : "http://localhost:8080/people{?page,size,sort}",
"templated" : true
},
"search" : {
"href" : "http://localhost:8080/people/search"
}
},
"_embedded" : {
"people" : [ {
"firstName" : "Frodo",
"lastName" : "Baggins",
"_links" : {
"self" : {
"href" : "http://localhost:8080/people/1"
}
}
}, {
"firstName" : "Frodo",
"lastName" : "shukla",
"_links" : {
"self" : {
"href" : "http://localhost:8080/people/2"
}
}
} ]
},
"page" : {
"size" : 20,
"totalElements" : 2,
"totalPages" : 1,
"number" : 0
}
}
为什么我用 _embedded 代替内容 _links 代替链接
而 rel 属性缺失..
我正在尝试将 json 反序列化回 hatos 资源,但由于格式更改,我无法做到这一点。
提前感谢您的帮助
【问题讨论】:
标签: rest spring-data-rest hateoas spring-hateoas