上传文件报错:The current request is not a multipart request] with root cause

不念不忘少年蓝@ 2022-06-06 07:19 308阅读 0赞

上传文件时报错:The current request is not a multipart request] with root cause

解决:在

标签加上 : enctype=”multipart/form-data”

参考:

上传文件的表单中要加属性enctype=”multipart/form-data”,如果不写enctype属性时,也默认为其添加了enctype属性值,默认值是enctype=”application/x- www-form-urlencoded”

上传文件报错:upload file springboot Required request part ‘file’ is not present

长传文件报错:Required request part ‘file’ is not present

解决:1、请查看参数名称等是否匹配;

  1. 2@RequestMapping注解加上:consumes = "multipart/form-data",如下:

@RequestMapping(value = “/form”, method = RequestMethod.POST, consumes = “multipart/form-data”)
public String handleFormUpload(@RequestPart(“file”) MultipartFile
file)

参考链接:https://stackoverflow.com/questions/43936372/upload-file-springboot-required-request-part-file-is-not-present

https://stackoverflow.com/questions/46071811/required-request-part-file-is-not-present-after-form-submission-in-spring-boot

https://stackoverflow.com/questions/42040261/missingservletrequestpartexception-required-request-part-file-is-not-present

发表评论

表情:
评论列表 (有 0 条评论,308人围观)

还没有评论,来说两句吧...

相关阅读