如何解决 angular 9 spring boot 应用程序中的错误 415?

我有来自 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"

我已经在 J​​ava 中查看了我的实体,并创建了一些字段作为 @JsonIgnore 以便到达底部 这没有成功。 415 是指映射错误还是我遗漏了什么?

yangyang103 回答:如何解决 angular 9 spring boot 应用程序中的错误 415?

问题是我有静态 final 字段,其中没有 @JsonIgnore。

本文链接:https://www.f2er.com/3721.html

大家都在问