AJAX post傳參后台獲取不到查詢參數。
網上找了各種方法,包括設置content-type,又是把json轉成json格式字符串,問題依然存在,但是把post改成get又可以獲取到,百思不得其解。
后來看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”,問題就得到了解決