zoukankan      html  css  js  c++  java
  • spring boot文件上传失败 SizeLimitExceededException

    文件上传失败

    • 前端报错 net::ERR_CONNECTION_RESET
    • 后端报错 org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException: the request was rejected because its size (xxxxxx) exceeds the configured maximum (xxxxxx)

    解决方案

    1. 配置文件
      application.yml
    spring:
      servlet:
        multipart:
          max-file-size: 100MB
          max-request-size: 200MB
    
    1. JAVA配置
    @Bean
    public MultipartConfigElement multipartConfigElement() {
    	long maxFileSize = 100l;
    	long maxRequestSize = 200l;
    	MultipartConfigFactory factory = new MultipartConfigFactory();
    	factory.setMaxFileSize(DataSize.of(maxFileSize ,MEGABYTES));
    	factory.setMaxRequestSize(DataSize.of(maxRequestSize ,MEGABYTES));
    	return factory.createMultipartConfig();
    }
    
  • 相关阅读:
    近期目标
    HDU
    BZOJ
    UVALive
    UVA
    HNOI2004 宠物收养所 (平衡二叉树)
    UVA
    HDU
    POJ
    康托展开与逆康托展开模板(O(n^2)/O(nlogn))
  • 原文地址:https://www.cnblogs.com/luguojun/p/14294744.html
Copyright © 2011-2022 走看看