且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AngularJS +弹簧:415不支持的媒体类型

更新时间:2023-09-07 12:08:22

HTTP错误415意味着,请求内容是不是在适当的格式。

An http error 415 means that content of request is not in the appropriate format.

Spring MVC的'@RequestBody期待一个JSON体(有内容类型等于'应用程序/ JSON')和你的内容类型明确设置为undefined。

Spring MVC '@RequestBody' expect a json body (with a Content-Type equal to 'application/json') and you explicitly set your Content-Type to undefined.

解决的办法是设置内容类型为应用程序/ JSON在您的文章的请求或删除@RequestBody注释。

The solution is to set your content-type to 'application/json' in your post request or to remove @RequestBody annotation.

看来你尝试上传文件时,更容易将删除@RequestBody注释。

It seems that you try to upload files, the easier would be to remove @RequestBody annotation.