gpt4 book ai didi

java - 无法解析多部分 Servlet 请求;嵌套异常是 org.apache.commons.fileupload.FileUploadException : Too many open files

转载 作者:行者123 更新时间:2023-11-30 06:51:39 25 4
gpt4 key购买 nike

我在强烈要求的 Controller 上的方法中遇到此错误。这是一个接收 JSON 的简单 POST。

这个方法是这样的:

@PostMapping("/")
@ResponseBody
public A query(B obj){
...
}

New Relic 显示以下堆栈跟踪:

Error message
org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: Too many open files

Sample stack trace
…ultipart.commons.CommonsMultipartResolver.parseRequest (CommonsMultipartResolver.java:168)

…part.commons.CommonsMultipartResolver.resolveMultipart (CommonsMultipartResolver.java:142)

…framework.web.servlet.DispatcherServlet.checkMultipart (DispatcherServlet.java:1099)

…ringframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:932)
...
caused by org.apache.commons.fileupload.FileUploadException: Too many open files
….apache.commons.fileupload.FileUploadBase.parseRequest (FileUploadBase.java:362)
…mons.fileupload.servlet.ServletFileUpload.parseRequest (ServletFileUpload.java:115)
…ultipart.commons.CommonsMultipartResolver.parseRequest (CommonsMultipartResolver.java:158)
…part.commons.CommonsMultipartResolver.resolveMultipart (CommonsMultipartResolver.java:142)
…framework.web.servlet.DispatcherServlet.checkMultipart (DispatcherServlet.java:1099)
…ringframework.web.servlet.DispatcherServlet.doDispatch (DispatcherServlet.java:932)
…pringframework.web.servlet.DispatcherServlet.doService (DispatcherServlet.java:897)
…gframework.web.servlet.FrameworkServlet.processRequest (FrameworkServlet.java:970)
org.springframework.web.servlet.FrameworkServlet.doPost (FrameworkServlet.java:872)
javax.servlet.http.HttpServlet.service (HttpServlet.java:707)
…g.springframework.web.servlet.FrameworkServlet.service (FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service (HttpServlet.java:790)
…undertow.servlet.handlers.ServletHandler.handleRequest (ServletHandler.java:85)

有人经历过这样的事情吗?

最佳答案

删除标题可以工作。当我从角度向我的 Spring Controller 发送发布请求时,我遇到了同样的问题。这是我的代码,使用 Angular 抛出了相同的错误。

let formData:FormData = new FormData();
formData.append('file', file, file.name);
let headers = new Headers();
headers.append('Content-Type', 'multipart/form-data')
headers.append('Accept', 'application/json');
let options = new RequestOptions({ headers: headers });
this.http.post(URL_API_REST + 'upload', formData, options)

注释掉下面的这一行可以解决问题,因为我没有在 Spring Controller 中处理 multipart/form-data:

headers.append('Content-Type', 'multipart/form-data')

关于java - 无法解析多部分 Servlet 请求;嵌套异常是 org.apache.commons.fileupload.FileUploadException : Too many open files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42656015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com