您的位置:首页 > 编程语言 > Java开发

java.lang.IllegalStateException: Post too large异常及其解决办法

2009-04-25 11:57 676 查看
使用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以上的数据了

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息