java.lang.IllegalStateException: Post too large異常及其解決辦法

來源:互聯網
上載者:User

使用tomcat,今天測試使用submit向後台傳值時出現這樣的錯誤java.lang.IllegalStateException: Post too large異常及其解決辦法,

 

網上搜到解決地址:http://hi.baidu.com/llscompazz/blog/item/88a4f0c33fb6d551b219a87b.html

---------------------------------------------------------------------------------------------

java.lang.IllegalStateException: Post too large異常及其解決辦法2008-03-25 17:25

今天做一個大資料量的提交,結果出現一個錯誤,說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以上的資料了

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.