什么导致 java.lang.IllegalStateException: Post too large in tomcat / mod_jk

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/123335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 08:33:43  来源:igfitidea点击:

What causes java.lang.IllegalStateException: Post too large in tomcat / mod_jk

javatomcatmod-jk

提问by masukomi

what configuration needs to be tweaked, and where does it live, in order to increase the maximum allowed post size?

需要调整什么配置,它在哪里,以增加允许的最大帖子大小?

采纳答案by Steve K

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 2 MB. When you try to upload files larger than 2 MB, this error can occur.

默认情况下,Apache Tomcat 对其接受的 HTTP POST 请求的最大大小设置了限制。在 Tomcat 5 中,此限制设置为 2 MB。当您尝试上传大于 2 MB 的文件时,可能会发生此错误。

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_DIR]/conf/server.xml. Set the Tomcat configuration parameter maxPostSize for the HTTPConnector to a larger value (in bytes) to increase the limit. Setting it to 0 in will disable the size check. See the Tomcat Configuration Referencefor more information.

解决方案是重新配置 Tomcat 以接受更大的 POST 请求,方法是增加限制或禁用它。这可以通过编辑 [TOMCAT_DIR]/conf/server.xml 来完成。将 HTTPConnector 的 Tomcat 配置参数 maxPostSize 设置为更大的值(以字节为单位)以增加限制。将其设置为 0 in 将禁用大小检查。有关更多信息,请参阅Tomcat 配置参考

回答by Ahmed MANSOUR

It will be for others persons, I see you are coupling Apache HTTP and Tomcat (tomcat / mod_jk), in this case edit the Coyote/JK2 AJP 1.3 Connector the same way you do it for the standard connector (Coyote HTTP/1.1), because the AJP1.3 Connector is where Tomcat receive data.

这将适用于其他人,我看到您正在耦合 Apache HTTP 和 Tomcat (tomcat / mod_jk),在这种情况下,编辑 Coyote/JK2 AJP 1.3 连接器的方式与您对标准连接器 (Coyote HTTP/1.1) 所做的相同,因为 AJP1.3 Connector 是 Tomcat 接收数据的地方。

<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector port="8009" 
           enableLookups="false" redirectPort="8443" debug="0"
           protocol="AJP/1.3" maxPostSize="0"/>

回答by user3829269

The root cause of IllegalStateException exception is a java servlet is attempting to write to the output stream after the response has been committed.

IllegalStateException 异常的根本原因是 Java servlet 在响应提交后试图写入输出流。

Take care that no content is added to the response after redirecting/dispatching request.

注意在重定向/分派请求后没有内容被添加到响应中。