fileupload.FileUploadException: the request was rejected because no multipart boundary was found

这篇具有很好参考价值的文章主要介绍了fileupload.FileUploadException: the request was rejected because no multipart boundary was found。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

前端小程序调用服务端的文件上传接口,有一台安卓机上传一直报错:

报错日志:

  • {"statusCode": 500, "header": {"Date": "Wed, 29 Mar 2023 06:45:39 GMT", "Content-Language": "en", "Server": "nginx", "Content-Type": "text/html;charset=utf-8", "Transfer-Encoding": "chunked", "Connection": "keep-alive", "protocol": "http/1.1"}, "data": "<!doctype html><html lang="en"><head><title>HTTP Status 500 – Internal Server Error</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 500 – Internal Server Error</h1><hr class="line" /><p><b>Type</b> Exception Report</p ><p><b>Message</b> Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found</p ><p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.</p ><p><b>Exception</b></p ><pre>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found\n\torg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1013)\n\torg.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)\n\tjavax.servlet.http.HttpServlet.service(HttpServlet.java:661)\n\torg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)\n\tjavax.servlet.http.HttpServlet.service(HttpServlet.java:742)\n\torg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\n\torg.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)\n\torg.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)\n\torg.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)\n\torg.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)\n\torg.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)\n\torg.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)\n\torg.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)\n\torg.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)\n\torg.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)\n\torg.springframework.mobile.device.site.SitePreferenceRequestFilter.doFilterInternal(SitePreferenceRequestFilter.java:56)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n\torg.springframework.mobile.device.DeviceResolverRequestFilter.doFilterInternal(DeviceResolverRequestFilter.java:60)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n\torg.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:108)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n\torg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n</pre><p><b>Root Cause</b></p ><pre>org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found\n\torg.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:168)\n\torg.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:142)\n\torg.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1176)\n\torg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1011)\n\torg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)\n\torg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)\n\torg.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)\n\tjavax.servlet.http.HttpServlet.service(HttpServlet.java:661)\n\torg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)\n\tjavax.servlet.http.HttpServlet.service(HttpServlet.java:742)\n\torg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\n\torg.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)\n\torg.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)\n\torg.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)\n\torg.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)\n\torg.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)\n\torg.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)\n\torg.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)\n\torg.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)\n\torg.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)\n\torg.springframework.mobile.device.site.SitePreferenceRequestFilter.doFilterInternal(SitePreferenceRequestFilter.java:56)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n\torg.springframework.mobile.device.DeviceResolverRequestFilter.doFilterInternal(DeviceResolverRequestFilter.java:60)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n\torg.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:108)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n\torg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n</pre><p><b>Root Cause</b></p ><pre>org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found\n\torg.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl.&lt;init&gt;(FileUploadBase.java:990)\n\torg.apache.commons.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:310)\n\torg.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:334)\n\torg.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:115)\n\torg.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:158)\n\torg.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:142)\n\torg.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1176)\n\torg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1011)\n\torg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)\n\torg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)\n\torg.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)\n\tjavax.servlet.http.HttpServlet.service(HttpServlet.java:661)\n\torg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)\n\tjavax.servlet.http.HttpServlet.service(HttpServlet.java:742)\n\torg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\n\torg.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)\n\torg.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)\n\torg.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)\n\torg.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)\n\torg.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)\n\torg.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)\n\torg.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)\n\torg.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)\n\torg.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)\n\torg.springframework.mobile.device.site.SitePreferenceRequestFilter.doFilterInternal(SitePreferenceRequestFilter.java:56)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n\torg.springframework.mobile.device.DeviceResolverRequestFilter.doFilterInternal(DeviceResolverRequestFilter.java:60)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n\torg.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:108)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n\torg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)\n\torg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)\n</pre><p><b>Note</b> The full stack trace of the root cause is available in the server logs.</p ><hr class="line" /><h3>Apache Tomcat/8.5.37</h3></body></html>", "cookies": [], "errMsg": "uploadFile:ok"} 123432123432 success

具体报错是这段
Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found

原因:

前端在上传照片时,headers写死了 content-type="multipart/form-data",导致浏览器无法在请求头加上boundary标识,产生冲突

fileuploadexception: the request was rejected because no multipart boundary,前端,java

解决方案:

前端headers设置 contentType:false或者注掉contentType,这样上传图片request请求会自动添加这个请求参数的格式和boundary标识,就不会报错了

fileuploadexception: the request was rejected because no multipart boundary,前端,java

 本文参考FileUploadException: the request was rejected because no multipart boundary was found_shangqing.liu的博客-CSDN博客文章来源地址https://www.toymoban.com/news/detail-777224.html

到了这里,关于fileupload.FileUploadException: the request was rejected because no multipart boundary was found的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • git 报错:Updates were rejected because the remote contains work that you do问题

    刚开始学习使用git,通过push命令:打算将本地仓库中的文件上传到远端仓库时,报了以下错误: 原因:远程仓库不为空:自己在创建远程仓库的时候,添加了如下两个文件,本地仓库中并没有这两个文件。 解决方法:添加:–allow-unrelated-histories 将远端的本地文件首先拉取到

    2024年02月11日
    浏览(45)
  • git报错:Updates were rejected because the tip of your current branch is behind

    多人协作项目,其他成员提交之后,你这边没有拉取最近代码就要进行推送,远程仓库和本地仓库不同步。 一般远程仓库和本地仓库是同步的,当有另一个人克隆远程仓库并修改推送代码后,你这边的本地仓库再进行推送会提示这个错误。“更新被拒绝,因为您当前分支的提

    2024年02月15日
    浏览(48)
  • The operation was rejected by your operating system. npm ERR! It‘s possible that the file was alrea

    在win10系统下安装node.js出现了如下的报错。 首先需要在安装node.js文件夹中自行创立这两个文件夹,node_global代表全局变量的文件夹,node_cache代表缓存的文件夹。 接下来要配置文件: 这里换成自己的路径即可。 接下来就是配置环境变量: 然后将用户变量中Path,关于node的环

    2024年02月12日
    浏览(30)
  • 成功解决:Updates were rejected because the tip of your current branch is behind its remote...【解决方法】

    最近使用git,一直使用命令行操作。昨天突发奇想研究了一番git的GUI,结果由于操作不当产生了如下报错: Updates were rejected because the tip of your current branch is behind its remote counterpart. 该报错在git push时出现,一句话解释就是你在本地仓库上的修改没有基于远程库最新版本,本地

    2024年02月12日
    浏览(44)
  • 【Github】hint: Updates were rejected because the remote contains work that you do && remote: error: G

    Q: git push 报错 翻译 A:这是因为在上传的时候,远程仓库中有着本地仓库没有的文件(与远程仓库的内容不一致),即导致本地仓库和远程有不同的开始点,也就是两个仓库没有共同的 commit ,所以无法提交,解决方法如下: 参考教程https://www.cnblogs.com/yanhuidj/p/9301328.html 正确的

    2024年02月03日
    浏览(32)
  • npm install安装失败,报错记录之The operation was rejected by your operating system.

    今天在执行 npm install 的时候一直报如下错误:  npm ERR! code EPERM npm ERR! syscall rename npm ERR! path F:Demo Practise一些小demo练习vue练习vue3vue3-demonode_modules@vuecli-service npm ERR! dest F:Demo Practise一些小demo练习vue练习vue3vue3-demonode_modules@vue.cli-service.DELETE npm ERR! errno -4048 npm ERR! Er

    2024年02月03日
    浏览(32)
  • 全网多种方法解决Updates were rejected because the remote contains work that you do not have locally的错误

    今天使用 git status 查看文件状态,发现有一个文件未提交,如下代码所示: 既然未提交,则首先使用 git add 将当前目录下修改的代码,从工作区添加到暂存区,如下代码所示: 接着使用 git commit 将缓存区内容添加到本地仓库,如下代码所示: 但使用 git push origin master 将本地

    2024年02月03日
    浏览(38)
  • 解决gitpush时报错:hint: Updates were rejected because the remote contains work that you do hint: not have

    当我新建了一个git仓库,依次执行 却报错 报这个错是因为远程仓库和本地仓库文件不同步,解决方法是先执行git pull将远程仓库文件拉下来使得远程与本地同步。 解决步骤 1.执行 这里的webbrowser换成你的远程仓库名 执行后会有如下输出 2.再试试重新推送行不行 发现还是报错

    2024年02月16日
    浏览(43)
  • The plain HTTP request was sent to HTTPS port

    异常信息 原因 错误信息 “The plain HTTP request was sent to HTTPS port” 表明客户端尝试使用未加密的HTTP协议发送请求到一个配置为使用加密的HTTPS协议的端口。 解决方案 要解决这个问题,需要确保使用正确的协议和端口号进行请求。应该使用的HTTPS前缀。例如: 错误的请求: ht

    2024年04月14日
    浏览(28)
  • ingress 400 Bad Request The plain HTTP request was sent to HTTPS port

      问题现象         访问时返回400 Bad Request,并提示 The plain HTTP request was sent to HTTPS port 。 问题原因         Ingress Controller到后端Pod请求使用了默认的HTTP请求,但后端是HTTPS服务。。 解决方案         添加注释,让其使用https请求 官方配置:Annotations - NGINX Ingres

    2024年02月12日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包