java 后台SSM+Maven 服务器nginx+tomcat上传大文件报错500 - FileUploadBase$SizeLimitExceededException

具体报错:

org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (371068104) exceeds the configured maximum (104857600);

下列是我的Nginx配置大小限制修改

http {
    include       mime.types;
    default_type  application/octet-stream;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;
    sendfile       on;
    tcp_nopush     on;
    tcp_nodelay    on;

    #keepalive_timeout  0;
    keepalive_timeout  650s;

    #重要的三句!!!!!!!!!
    client_max_body_size 1024m;
	client_body_buffer_size 2048m;#尽量设置的大点,这是基于速度的考虑,如果因为设置的过小,导 
    致上传的文件老要写磁盘,那速度就太慢了。
    large_client_header_buffers 4 2048m;
	

	#gzip on;
	gzip_min_length 1k;
	gzip_buffers 4 16k;
	gzip_http_version 1.1;
	gzip_comp_level 9;
	gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
	gzip_vary off;
	gzip_disable "MSIE [1-6]\.";
	
	upstream zjjinshi {
		server 127.0.0.1:8080;
       }
	   
	
    server {
        listen       80;
        server_name  www.baidu.com;#80端口关联的域名
		
		client_max_body_size 1024m;
	    client_body_buffer_size 2048m;
		large_client_header_buffers 4 2048m;


        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
			# 请求转发给 Tomcat 集群处理

            
			client_max_body_size 1024m;
	        client_body_buffer_size 2048m;


            proxy_pass http://zjjinshi;
			
        }

网上也有说 tomcat 下webapps/manager/WEB-INF/web.xml  更改如下:

我已改好的最大上传数据500mb根据实际情况更改(但是我觉得以上更改后都没任何作用(我目前的项目))

<multipart-config>
      <!-- 500MB max -->
      <max-file-size>524288000</max-file-size>
      <max-request-size>524288000</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>

最后在项目的web层中找到配置文件(就是这里配置错了害我找半天  呜呜呜~):springmvc.xml 更改数据如下:

<!-- 文件上传解析器 -->

   <bean id="multipartResolver" 

        class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="1048576000" />//就是这里配置错了,限制大小为 
         100mb,现在我有加了个0,最大上传为1000mb。
        <property name="maxInMemorySize" value="4096" />
        <property name="defaultEncoding" value="UTF-8"></property>
    </bean>    

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章