Spring Boot 报错 the request was rejected because no multipart boundary was found
Spring Boot About 1,973 words错误信息
the request was rejected because no multipart boundary was found
org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.handleParseFailure(StandardMultipartHttpServletRequest.java:122)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.parseRequest(StandardMultipartHttpServletRequest.java:110)
at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest.<init>(StandardMultipartHttpServletRequest.java:86)
at org.springframework.web.multipart.support.StandardServletMultipartResolver.resolveMultipart(StandardServletMultipartResolver.java:112)
Caused by: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
at org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl.init(FileItemIteratorImpl.java:189)
at org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl.getMultiPartStream(FileItemIteratorImpl.java:205)
at org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl.findNextItem(FileItemIteratorImpl.java:224)
at org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl.<init>(FileItemIteratorImpl.java:142)
at org.apache.tomcat.util.http.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:252)
at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:276)
at org.apache.catalina.connector.Request.parseParts(Request.java:2800)
at org.apache.catalina.connector.Request.getParts(Request.java:2701)
at org.apache.catalina.connector.RequestFacade.getParts(RequestFacade.java:774)
问题原因
前端上传文件时,手动设置了Content-Type
。
Content-Type: multipart/form-data;
解决方法
前端无需手动设置Content-Type
,浏览器会自动加上boundary
。
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBM8Ye5Bu7Y1OUqAf
Views: 1,126 · Posted: 2024-03-25
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...