Est*_*iro 8 java upload spring-boot
我正在尝试使用 springboot 制作一个简单的上传应用程序,它运行良好,直到我尝试上传 10Mb 以上的文件,我在屏幕上收到此消息:
There was an unexpected error (type=Internal Server Error, status=500).
Could not parse multipart servlet request; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (14326061) exceeds the configured maximum (10485760)
Run Code Online (Sandbox Code Playgroud)
我做了一些研究,直到现在还没有任何效果。我将在我迄今为止尝试过的事情下面离开这里。
将此代码(以各种方式)放在我的“application.yml”中
multipart:
maxFileSize: 51200KB
maxRequestFile: 51200KB
Run Code Online (Sandbox Code Playgroud)
我也在我的主要课程中尝试过这个:
@Bean
public TomcatEmbeddedServletContainerFactory containerFactory() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSwallowSize(-1);
}
});
return factory;
}
Run Code Online (Sandbox Code Playgroud)
还有一些奇怪的事情。如果我输入我的 tomcat web.xml,multipart-config 是:
<multipart-config>
<!-- 50MB max -->
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
Run Code Online (Sandbox Code Playgroud)
那么这个“...配置最大值(10485760)”到底来自哪里?(旁注:我使用的是 netbeans 8.1 和 springboot 1.5)。
谢谢伙计们。(对不起英语s2)
既然问了,这是我的 application.yml
server:
port: 9999
context-path: /client
logging:
level:
org.springframework.security: DEBUG
endpoints:
trace:
sensitive: false
spring:
thymeleaf:
cache: false
multipart:
maxFileSize: 51200KB
maxRequestFile: 51200KB
#################################################################################
security:
basic:
enabled: false
oauth2:
client:
client-id: acme2
client-secret: acmesecret2
access-token-uri: http://localhost:8080/oauth/token
user-authorization-uri: http://localhost:8080/oauth/authorize
resource:
user-info-uri: http://localhost:8080/me
#
Run Code Online (Sandbox Code Playgroud)
spring:
http:
multipart:
enabled: true
max-file-size: 50MB
max-request-size: 50MB
Run Code Online (Sandbox Code Playgroud)
或者
spring.http.multipart.max-file-size=50MB
spring.http.multipart.max-request-size=50MB
Run Code Online (Sandbox Code Playgroud)
参考这里
希望它会起作用
以下是基于版本的方法,
第一:
spring.servlet.multipart.max-file-size=1000MB
spring.servlet.multipart.max-request-size=1000MB
Run Code Online (Sandbox Code Playgroud)
第二:
spring.http.multipart.max-file-size=50MB
spring.http.multipart.max-request-size=50MB
Run Code Online (Sandbox Code Playgroud)
第三:
multipart.enabled=true
multipart.max-file-size=100MB
multipart.max-request-size=100MB
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17389 次 |
| 最近记录: |