今天做一個大資料量的提交,結果出現一個錯誤,說Post too large... 另還有句提示,就是Parameters were not parsed because the size of the posted data was too big. Use the maxPostSize attribute of the connector to resolve this if the application should accept large POSTs. 這個錯誤不知道是不是國內的人很少遇到,沒幾個人寫出來.後來我在國外的網站上找到了原因和解決辦法: Q: In Tomcat, I got a "Post data too big" error. A: Apache Tomcat by default sets a limit on the maximum size of HTTP POST requests it accepts. In Tomcat 5, this limit is set to 2097152 (2 Mb). When you try to upload files or post forms that are larger than 2 MB, this error can occur. The solution is to reconfigure Tomcat to accept larger POST requests, either by increasing the limit, or by disabling it. This can be done by editing Tomcat's server.xml. In the <Connector> element, add an attribute "maxPostSize" and set a larger value (in bytes) to increase the limit. Setting it to 0 will disable the size check. 意思是說,tomcat預設設定能接收HTTP POST請求的大小最大為2M,如果你的POST請求傳遞的資料大於2M,就會報這個錯誤.解決的辦法是修改tomcat的設定檔$TOMCAT_HOME$/conf/server.xml,找到裡面的<Connector>標籤,在該標籤中添加"maxPostSize"屬性,將該屬性值設定成你想要的最大值,單位是位元組,如果你把這個值設定為0(maxPostSize="0"),tomcat將不再檢查POST的大小. ---------------------------------------------------------------------------------------------- 我修改了我的tomcat設定檔; <Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="gb2312" maxPostSize="0"/> 現在可以post正常傳遞2M以上的資料了 |