Home  >  Article  >  Java  >  How to solve the error when uploading file in springboot is too large

How to solve the error when uploading file in springboot is too large

王林
王林forward
2023-05-18 14:40:063821browse

1. Springboot 2.1.0 reports an error when the upload file is too large

Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http. fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (216185201) exceeds the configured maximum (104857600)

2. Solution:

1 .Check whether Nginx can limit the request data size

server {

listen 80;

#server_name localhost;

client_max_body_size 500M;

              #charset koi8-r;

              #access_log logs/host.access.log   main;

location /test/ {

proxy_pass http://127.0.0.1:8080/test/;

}

}

Among them: client_max_body_size 500M; must be opened, release restrictions

3. Check whether tomcat can limit the request data size

In D:\Program Files\Apache Software Foundation\Tomcat 8.5\conf\server.xml

##             connectionTimeout="20000"

                                                                                                                                                        connectionTimeout="20000"

                                  maxPostSize=" -1"

##                             redirectPort="8443" />

maxPostSize sets the request size, -1 means no limit

4.springboot Set request size limit

Configure in application.properties:

spring.servlet.multipart.max-file-size=500MB

spring.servlet.multipart.max-request-size=500MB######

The above is the detailed content of How to solve the error when uploading file in springboot is too large. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete