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>    

 

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