When the jetty plug-in of eclipse is used as the server to submit data in rich text editing, the following exception is reported:
java.lang.IllegalStateException: Form too large270468>200000at org.mortbay.jetty.Request.extractParameters(Request.java:1561)at org.mortbay.jetty.Request.getParameterMap(Request.java:870)at org.apache.struts2.dispatcher.Dispatcher.createContextMap(Dispatcher.java:528)at org.apache.struts2.dispatcher.ng.PrepareOperations.createActionContext(PrepareOperations.java:78)at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:74)at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)at org.mortbay.jetty.Server.handle(Server.java:326)at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
It is obvious that the data in a single request is too large. form too large> 200000 (200000 means that 200000byte is about 2 m), but where did the exception be thrown? After some research, the jetty plug-in reports the following:
In the \ eclipse \ plugins directory, find Org. mortbay. jetty. server_6.1.23.v201012071420.jar package, thrown into the JD-GUI, according to the error message Org. morbay. jetty. request. the following information is found in the extractparameters () method:
Note that the exception is thrown here, but the maxformcontentsize value is from there, according to this. _ context. getcontexthandler (). getmaxformcontentsize (): Find Org. mortbay. jetty. handlercontexthandler. class, the result shows that the class has the following sentence, excited, default value here.
So this default value is set. How to modify it? You can see this in the request class. _ context. getcontexthandler (). getmaxformcontentsize () code to continue tracing. This value should be obtained from the web entry, that is, Web. XML, but how to pass this value in it, after the online search and practice, you can create a new WEB-INF file under the jetty-web.xml Directory, which writes the following content, you can assign a value to maxformcontentsize again (jetty6 applies ):
<?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>
Restart the web application and submit data again. The problem can be solved successfully.
If there are any similar situations on other servers, the answer is certainly yes. For example, Tomcat found the following content through search:
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)
Increase the limit. Setting it to 0 will disable the size check.
It means that by default, Tomcat sets a maximum size of 2 MB for receiving http post requests. If the data transmitted by your POST request is greater than 2 MB, this error will be reported. the solution is to modify the tomcat configuration file $ tomcat_home $/CONF/server. XML, find the <connector> tag in the tag, add the "maxpostsize" attribute to the tag, and set the attribute value to the maximum value, in bytes, if you set this value to 0 (maxpostsize = "0"), Tomcat will no longer check the post size.
My testing environment is as follows:
Jetty version: Run jetty run feature1.2.2.1
Jar package version for jetty: org. mortbay. Jetty. server_6.1.23.v201012071420.jar
For jetty7, you only need to change the package path. The complete configuration file is as follows:
<?xml version="1.0"?> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> <Configure id="WebAppContext" class="org.eclipse.jetty.webapp.WebAppContext"> <Set name="maxFormContentSize" type="int">600000</Set> </Configure>
Sorry, you're done!