0
Spring Data Rest Endpointを呼び出すと、各オブジェクト内の自己リンクと関連リンクが表示されます。いずれのリンクも表示されません。Spring内のリンクが欠落していますRestTemplateを使用したレスポンス
RestTemplateセットアップ:
@HystrixCommand(fallbackMethod = "getFallbackScenicList")
@RequestMapping(value = "/s", method = RequestMethod.GET, produces= MediaType.APPLICATION_JSON_VALUE)
public PagedResources<Scenic> scenic() {
String url = "http://vr-dms-an-scenic/scenic";
ParameterizedTypeReference<PagedResources<Scenic>> ptr = new ParameterizedTypeReference<PagedResources<Scenic>>() {};
ResponseEntity<PagedResources<Scenic>> responseEntity =
this.restTemplate.exchange(url,HttpMethod.GET, null, ptr, 0,100
);
PagedResources<Scenic> resources = responseEntity.getBody();
return resources;
}
必要な応答:
{
"_embedded": {
"scenic": [
{
"id": 1,
"name": "Test1 scenic",
"description": "This is a description1 for displaying information while in development",
"shortDescription": "Short Description Scenic1",
"_links": {
"self": {
"href": "http://localhost:49218/scenic/1"
},
"scenic": {
"href": "http://localhost:49218/scenic/1"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:49218/scenic"
},
"profile": {
"href": "http://localhost:49218/profile/scenic"
},
"search": {
"href": "http://localhost:49218/scenic/search"
}
},
"page": {
"size": 20,
"totalElements": 1,
"totalPages": 1,
"number": 0
}
}
実際の応答は:
{
"_embedded": {
"scenic": [
{
"id": 1,
"name": "Test1 scenic",
"description": "This is a description1 for displaying information while in development",
"shortDescription": "Short Description Scenic1"
}
]
},
"_links": {
"self": {
"href": "http://localhost:49218/scenic"
},
"profile": {
"href": "http://localhost:49218/profile/scenic"
},
"search": {
"href": "http://localhost:49218/scenic/search"
}
},
"page": {
"size": 20,
"totalElements": 1,
"totalPages": 1,
"number": 0
}
}
まあを、したいです。ありがとう。 – code