通过Postman上传文件出现如下错误信息:

“error”: “Internal Server Error”,
“exception”: “org.springframework.web.multipart.MultipartException”,
“message”: “Current request is not a multipart request”, “path”: “/upload”

错误原因:Headers填写错误,可能是之前选错x-www-form-urlencoded或其他类型。

Postman文件上传报错:The current request is not a multipart request解决方法插图

解决方案:

第一步,删除Header中关于Content-Type的配置。

第二,Body中的配置选择如下:

Postman文件上传报错:The current request is not a multipart request解决方法插图1

然后请求,接口解决上述问题。

对应的Controller实现如下:

	/**
	 * 从Excel导入会员列表
	 */
	@RequestMapping(value = "/import1", method = RequestMethod.POST)
	@ResponseBody
	public void importMemberList(@RequestPart("file") MultipartFile file) throws IOException {

	}

注意,MultipartFile的名字要与PostMan中file保持一致。



Postman文件上传报错:The current request is not a multipart request解决方法插图2

关注公众号:程序新视界,一个让你软实力、硬技术同步提升的平台

除非注明,否则均为程序新视界原创文章,转载必须以链接形式标明本文链接

本文链接:http://www.choupangxia.com/2022/07/31/postman/