MissingServletRequestPartException: Required request part 'file' is not present
时间: 2023-10-15 17:24:44 浏览: 130
TypeError: ‘required’ is an invalid argument for positionals 的解决方法
5星 · 资源好评率100%
MissingServletRequestPartException: Required request part 'file' is not present是一个错误,它表示在请求中缺少了名为'file'的必需的参数。
这个错误通常在后端使用@RequestParam或@RequestBody注解来接收文件参数时出现。在前端的请求中必须确保文件上传的参数名与后端接收参数的注解中的参数名保持一致。例如,在前端使用formData.append('file',this.file.raw)来上传文件,则后端的@RequestParam或@RequestBody注解中的参数名应为'file'。
如果错误依然存在,可能是因为在前端的文件input标签中的name字段与后端注解中的参数名不一致导致的。请确保它们的命名一致。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [MissingServletRequestPartException: Required request part ‘file‘ is not present问题](https://blog.csdn.net/weixin_43862596/article/details/118926572)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [MissingServletRequestPartException:Required request part ‘file‘ is not present上传文件报错](https://blog.csdn.net/HQXQ2874760112/article/details/124676049)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文