文件上传报错:Current request is not a multipart request

  |   java

我使用springboot实现上传文件功能,并将上传好文件保存到指定目录下。当postman测试上传文件接口出现报错了信息,如何解决问题,并正确设置postman配置。

{
    "timestamp": "2018-12-31 12:30:12",
    "status": 500,
    "error": "Internal Server Error",
    "exception": "org.springframework.web.multipart.MultipartException",
    "message": "Current request is not a multipart request",
    "path": "/upload"
}

报错信息的是Current request is not a multipart request
原因是Headers头部勾选Content-Type选错了application/x-www-form-urlencoded,所以要取消勾选,才能上传成功!

{
    "msg": "上传成功",
    "result": true,
    "data": "/Users/zhouyulong/gogs/Spring-Boot-Shiro/src/main/webapp/upload/c18127d2-cd14-435b-8172-1f3f67596208.jpg"
}

以上解决了问题,可以正常上传