那么这个默认值是设置好的,如何修改呢,通过看Request类里的this._context.getContextHandler().getMaxFormContentSize()代码,继续追踪,该值应该是从WEB的入口获取的即web.xml,但是这个值如何传进去呢,经过网上的搜索与实践,可以在WEB-INF目录下新建一个jetty-web.xml文件,里面写如下内容,对maxFormContentSize重新赋值即可(Jetty6适用):
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN""http://jetty.mortbay.org/configure.dtd"><Configure id="WebAppContext" class="org.mortbay.jetty.webapp.WebAppContext"><Set name="maxFormContentSize" type="int">600000</Set></Configure>重新启动web应用,再次提交数据,发现可以正常提交了,到此,问题圆满解决。 那么其它服务器有没有类似情况,答案当然是肯定的,如Tomcat,通过搜索找到了如下内容:
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.