我有来自 angular 9 应用程序的以下代码,它是一种发送许多字段的 post 方法:
const httpoptions = {
headers: new HttpHeaders({ 'accept': 'application/json','Content-Type': 'application/json' })
};
return this.http.post(`${AppComponent.API}/Trip/Add`,JSON.stringify(trip),httpoptions);
这是对应的休息控制器:
@PostMapping("/Trip/Add")
public Integer addFund(@RequestBody Trip trip) {
return tripService.addTrip(trip);
}
这是浏览器日志中的错误:
zone-evergreen.js:2952 POST http://localhost:9019/trips/trip/Add 415 "Unsupported Media Type"
我已经在 Java 中查看了我的实体,并创建了一些字段作为 @JsonIgnore 以便到达底部 这没有成功。 415 是指映射错误还是我遗漏了什么?