【发布时间】:2021-10-27 11:42:34
【问题描述】:
我正在使用 Spring Boot Server 开发 reactjs。 当通过 axios 从 reactjs 进行映射后调用以检索对象列表时,不知何故,我只能获取第一个对象,而其他对象仅显示 id。代码如下:
反应端
checkAllOffer(){
axios.post("http://localhost:8080/post/getAllOffer/"+ this.state.id)
.then(response => {
console.log(response.data);
})
}
Spring Boot 端
控制器方法
@PostMapping("/post/getAllOffer/{id}")
public List<Offer> checkOwnOffer(@PathVariable("id") int postId)
{
CarPosting currentPost = cpservice.findCarPostById(postId);
List<Offer>allCurrentOfferForCurrentPost = currentPost.getOffers();
return allCurrentOfferForCurrentPost;
}
spring boot 打印数据很好
但在控制台端,记录详细信息显示对象 2 缺少信息
【问题讨论】:
-
JSON.stringify(response.data)的输出是什么? -
什么也没有出现。甚至不是数组中的第一个对象
标签: java reactjs spring-boot