“错误”:上传文件控制器上的“不支持的媒体类型”

问题描述

我有一个处理 PDF 文件的简单项目。我正在尝试编写文件上传控制器。 我已经尝试了很多方法来做到这一点,但它一直给我这个错误

Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=----WebKitFormBoundarykuss6O97yqzGx0dG' not supported]

这是我的代码

@PostMapping (value = "/setTemplateContent",consumes = MediaType.APPLICATION_PDF_VALUE)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value= "Get contract and pdf. Save Pdf in Contract",notes = "Convert pdf to ByteArray")
@ResponseBody
public void setTemplateContent(@RequestParam("file") multipartfile file)
        throws IOException {
}

我正在使用 Swagger UI 发送请求。

Swagger Post Method Image

我什至尝试实现 Spring 官方指南网站上的“入门”示例。我看不出我的问题在哪里。你能帮我看看我的问题吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)