1. 程式人生 > >tomcat7以上,設定maxPostSize="0"引數後臺獲取不到的問題

tomcat7以上,設定maxPostSize="0"引數後臺獲取不到的問題

遇到兩次這個問題,記錄一下。
登入的時候後臺獲取不到驗證碼,本地環境是tomcat7.32,伺服器是tomcat7.82,一樣的配置,本地沒有發生這樣的情況。查詢資料發現tomcat7配置的時候,把maxPostSize=”0”的配置去掉的時候問題消失。

根據以往的經驗,maxPostSize=”0”不就是不限制post資料的大小的麼,怎麼還反倒限制了資料的大小了呢?

因為專案裡面要post一個數據到後臺儲存(大小可能大於2M),所以這大小就不能限制。

再後來在tomcat的官方文件裡發現了這個maxPostSize的變動。

tomcat6.0的文件裡說maxPostSize不限制的設定是小於等於0

原話:The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The feature can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).

tomcat7.0的文件裡面說maxPostSize不限制的設定是小於0

原話:The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than zero. If not specified, this attribute is set to 2097152 (2 megabytes). Note that theFailedRequestFilter can be used to reject requests that exceed this limit.

所以把maxPostSize設定成“-1”,問題就得到了解決