对应的配置属性文件:org.springframework.boot.autoconfigure.web.servlet.MultipartProperties

SpringBoot 上传文件大小限制,SizeLimitExceededException: the request was rejected because its size (64042302) exceeds the configured maximum (10485760)

 

 由于我是yml文件,所以直接这样定义就行,无需定义bean了

 

可以自行分析org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration.DispatcherServletRegistrationConfiguration#dispatcherServletRegistration方法

SpringBoot 上传文件大小限制,SizeLimitExceededException: the request was rejected because its size (64042302) exceeds the configured maximum (10485760)

 

 

 

再看以下对应的multipart的自动配置文件:org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration

SpringBoot 上传文件大小限制,SizeLimitExceededException: the request was rejected because its size (64042302) exceeds the configured maximum (10485760)

 

 然后就一清二楚了,如果需要更清晰的步骤,剩下的就是Debug分析了

 

yml文件的值都有对应的类型转换Conver的,这是DataSize对应的yml文件转换类:org.springframework.boot.convert.StringToDataSizeConverter;DataSize内部根据提供的 70MB 值进行正则匹配组,然后进行一个实例化填充到自动属性文件中的

 

OK,BYe~~~~~~~~~~~~~~~

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-10
  • 2021-08-31
  • 2021-09-26
猜你喜欢
  • 2021-09-24
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
相关资源
相似解决方案