【发布时间】:2015-05-06 02:07:25
【问题描述】:
我正在使用 Spring Boot。我在控制器中调用的方法如下所示:
@RequestMapping(value = "/{customerId}/files/{id}/addFile", method = RequestMethod.POST,
produces = "application/json; charset=UTF-8")
@ResponseBody
public Response uploadFile(@PathVariable String customerId, @PathVariable String id,
@RequestParam("uploadedFile") MultipartFile file) throws IOException {
升级到 Tomcat 8 后,调用此方法时出现以下错误。我在从未到达的第一行设置了一个断点。:
org.springframework.web.util.NestedServletException: 请求 处理失败;嵌套异常是 org.springframework.web.multipart.MultipartException:无法解析 多部分 servlet 请求;嵌套异常是 java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException:流 关闭
有人遇到过这个问题吗?
【问题讨论】:
-
你可以发布你的 pom.xml 或者你的构建工具的任何配置。
-
我无法发布我的 pom.xml 但我可以确认当我的父 pom 升级以下内容时这种情况开始发生:spring-boot 1.1.5.RELEASE 到 1.1.8.RELEASE & tomcat 7.0 .54 到 8.0.12
-
您是否尝试过更新版本的 Tomcat 8? 8.0.20 是撰写本文时的最新版本。此外,还有一个 getting started guide 用于使用 Spring Boot 上传文件。它适用于 Tomcat 8。也许您可以查看指南并找出您的应用程序有什么不同。
-
我尝试过 Tomcat 8.0.20,但遇到了同样的问题。指南中的控制器看起来和我上面做的一样。 :/ 感谢您的帮助。
标签: spring-boot tomcat8