【发布时间】:2020-02-04 15:30:54
【问题描述】:
我正在尝试从我的 rest api 获取 json 响应,但我得到了这种格式!
我使用了@RestController 注释,我得到了“_embedded”!我不知道如何更改它,因为在我的前端应用程序中我不能使用这种格式!
@RestController
public class HeroRestController {
@Autowired
private HeroRepository HeroRepo;
@GetMapping("/heroes")
public List<Hero> getMessage(){
return HeroRepo.findAll();
}
}
我得到了什么:
{
"_embedded" : {
"heroes" : [ {
"name" : "hero11",
"_links" : {
"self" : {
"href" : "http://localhost:8009/heroes/2"
},
"hero" : {
"href" : "http://localhost:8009/heroes/2"
}
}
}, {
"name" : "hero22",
"_links" : {
"self" : {
"href" : "http://localhost:8009/heroes/3"
},
"hero" : {
"href" : "http://localhost:8009/heroes/3"
}
}
}
【问题讨论】:
标签: spring-boot