我正在尝试使用 SpringBoot 从客户端发送 Excel,但是当我获取 File 时出现错误。我在我的属性中添加了最大 10MB 或 300MB,但它不运行。
org.apache.tomcat.util.http.fileupload.FileUploadBase$FileSizeLimitExceededException:字段 uploadFile 超出了其最大允许大小 1048576 字节。在 org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl$FileItemStreamImpl$1.raiseError(FileUploadBase.java:630) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.apache .tomcat.util.http.fileupload.util.LimitedInputStream.checkLimit(LimitedInputStream.java:76) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 位于 org.apache.tomcat.util.http。 fileupload.util.LimitedInputStream.read(LimitedInputStream.java:135) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 java.io.FilterInputStream.read(未知来源) ~[na:1.8。 0_171] 在 org.apache.tomcat.util.http.fileupload.util.Streams.copy(Streams.java:98) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.apache. tomcat.util.http.fileupload.util.Streams.copy(Streams.java:68) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 位于 org.apache.tomcat.util.http.fileupload .FileUploadBase.parseRequest(FileUploadBase.java:293) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.apache.catalina.connector.Request.parseParts(Request.java:2869) ~[ tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.apache.catalina.connector.Request.parseParameters(Request.java:3216) ~[tomcat-embed-core-8.5.27.jar:8.5 .27] 在 org.apache.catalina.connector.Request.getParameter(Request.java:1137) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.apache.catalina.connector.RequestFacade .getParameter(RequestFacade.java:381) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:75) ~[spring- web-4.3.14.RELEASE.jar:4.3.14.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.14.RELEASE.jar:4.3 .14.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.apache.catalina.core .ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) ~[ spring-web-4.3.14.RELEASE.jar:4.3.14.RELEASE] 在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.3.14.RELEASE.jar :4.3.14.RELEASE] 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.apache.catalina .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) ~[tomcat-embed-core-8.5.27.jar:8.5.27] 位于 org.apache。
我的 pom.xml
在我的 pom.xml 中,我有版本 1 和 1.15.10 释放
<groupId>tutorial</groupId>
<artifactId>tutorial</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>tutorial</name>
<description>Demo project for tutorial CRUD</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
Run Code Online (Sandbox Code Playgroud)
我在 application.properties 中添加了...什么也没有。
maxFileSize: 300Mb
maxRequestSize: 300Mb
Run Code Online (Sandbox Code Playgroud)
编辑:但是我可以从 SpringBoot 下载此文件。但我无法发送此文件以读取内容
您需要设置不同的属性来增加上传大小:
spring.http.multipart.max-file-size=1Mb
spring.http.multipart.max-request-size=10Mb
Run Code Online (Sandbox Code Playgroud)
顺便说一句:Spring Boot 2 的前缀已更改。它就在spring.servlet那里。但由于您使用的是 1.5,因此上述内容应该适合您。
还有一个关于 Spring Boot 2 的优秀教程:https ://spring.io/guides/gs/uploading-files/
| 归档时间: |
|
| 查看次数: |
2243 次 |
| 最近记录: |