Jetty提交数据时报java.lang.IllegalStateException: Form too large270468>200000问题解决
来源:互联网 发布:ibeer啤酒软件下载 编辑:程序博客网 时间:2024/06/05 16:57
今天在使用Eclipse的Jetty插件做为服务器提交富文本编辑中的数据时,报如下异常:
- java.lang.IllegalStateException: Form too large270468>200000
- at 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)
在\eclipse\plugins目录下,找到org.mortbay.jetty.server_6.1.23.v201012071420.jar包,扔进JD-GUI中,根据报错提示信息org.morbay.jetty.Request.extractParameters()方法中找到如下信息:
注意观察箭头所示部分,异常应该是这儿抛出来的,但maxFormContentSize值是从那里来的呢,依据this._context.getContextHandler().getMaxFormContentSize()这句提示,找到org.mortbay.jetty.handlerContextHandler.class类,结果发现该类中有如下一句,兴奋,默认值在此。
那么这个默认值是设置好的,如何修改呢,通过看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>
那么其它服务器有没有类似情况,答案当然是肯定的,如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.
意思是说,tomcat默认设置能接收HTTP POST请求的大小最大为2M,如果你的POST请求传递的数据大于2M,就会报这个错误.解决的办法是修改tomcat的配置文件$TOMCAT_HOME$/conf/server.xml,找到里面的<Connector>标签,在该标签中添加"maxPostSize"属性,将该属性值设置成你想要的最大值,单位是字节,如果你把这个值设置为0(maxPostSize="0"),tomcat将不再检查POST的大小.
本人测试环境如下:
Jetty版本:Run Jetty Run Feature1.2.2.1
Jetty对应的jar包版本:org.mortbay.jetty.server_6.1.23.v201012071420.jar
对于Jetty7只需改下包的路径,完整配置文件如下:
- <?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>
- Jetty提交数据时报java.lang.IllegalStateException: Form too large270468>200000问题解决
- Jetty提交数据时报java.lang.IllegalStateException: Form too large270468>200000问题解决
- Jetty提交数据时报java.lang.IllegalStateException: Form too large270468>200000问题解决
- Jetty提交数据时报java.lang.IllegalStateException: Form too large270468>200000问题解决
- Jetty提交数据时报java.lang.IllegalStateException: Form too large270468>200000问题解决
- Jetty提交数据时报java.lang.IllegalStateException: Form too large270468>200000问题解决
- Jetty提交数据时报java.lang.IllegalStateException: Form too large问题解决
- Jetty 报 java.lang.IllegalStateException: Form too large
- java.lang.IllegalStateException: Form too large305887>200000
- jetty报类似java.lang.IllegalStateException: Form too large206383>200000错误的解决办法
- 使用Jetty启动WEB,请求报错java.lang.IllegalStateException: Form too large: 206150 > 200000
- Jetty7.6 java.lang.IllegalStateException: Form too large 563410>200000或Form too many keys异常
- jetty7报类似java.lang.IllegalStateException: Form too large366383>200000错误的解决办法
- Jetty java.lang.IllegalStateException: Committed
- java.lang.IllegalStateException问题解决
- okhttp请求数据时报错,输出java.lang.IllegalStateException: closed
- java.lang.IllegalStateException: !(Jetty || Servlet 3.0 || ContinuationFilter)
- 处理eclipse启动时报java.lang.IllegalStateException
- 国际化和本地化中的使用
- MSP430F149嵌入式系统中FLASH K9F1G08U0M的应用
- 身份证号正则校验(js校验+JAVA校验)
- 2012年5月SAT香港真题解析
- java连接mysql数据库
- Jetty提交数据时报java.lang.IllegalStateException: Form too large270468>200000问题解决
- Oracle数据泵导入导出 Oracle impdp/expdp
- virtualbox中安装ubuntu
- Unity5 如何做资源管理和增量更新
- Nginx配置proxy_pass
- RT-Thread内核之线程调度(三)
- nginx的 CPU参数worker_processes和worker_cpu_affinity使用说明
- Python Paste.deploy 笔记
- 用Apache Kafka构建流数据平台