1. If the interface request error is caused by nginx
Check the configuration in nginx:
http {
client_max_body_size 100m;
}
or:
location ^~ /aaa/ {
client_max_body_size 100m;
client_body_buffer_size 128k;
}
2. If it is caused by the interface
Tomcat is used as the web container
For example, for springboot 2.X or above, configure the following
spring:
servlet:
multipart:
# Open configuration
enabled: true
# Upload file size limit
max-request-size: 100MB
max-file-size: 100MB
3. Why is it configured like this? The reasons are as follows:
MultipartProperties attribute class
@ConfigurationProperties(prefix = "spring.servlet.multipart", ignoreUnknownFields = false)
public class MultipartProperties {
spring Enable configuration switch
Is spring.servlet.multipart.enabled true?
MultipartAutoConfiguration
@AutoConfiguration
@ConditionalOnClass({ Servlet.class, StandardServletMultipartResolver.class, MultipartConfigElement.class })
@ConditionalOnProperty(prefix = "spring.servlet.multipart", name = "enabled", matchIfMissing = true)
@ConditionalOnWebApplication(type = Type.SERVLET)
@EnableConfigurationProperties(MultipartProperties.class)
public class MultipartAutoConfiguration {