今天在本机测试一个图片上传接口的时候遇到错误
java.lang.IllegalStateException: Form too large 1105723>200000
看到异常是jetty抛出来的,看描述是form方式提交的post请求内容超过了限定值。我们是一个web项目,使用的jetty-maven-plugin这个插件。
网络上有一些直接加在pom的设置,比如
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
<configuration>
<scanIntervalSeconds>1</scanIntervalSeconds>
<webApp>
<contextPath>/${project.build.finalName}</contextPath>
</webApp>
<systemProperties>
<systemProperty>
<name>org.eclipse.jetty.server.Request.maxFormContentSize</name>
<value>10485760</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
以上配置适用用jetty插件8
jetty9的解决办法
修改pom.xml
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.3.v20140905</version>
<configuration>
<jettyXml>
src/main/resources/jetty/jetty.xml
</jettyXml>
</configuration>
</plugin>
添加一个文件到classpath即可
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
<Arg>-1</Arg>
</Call>
</Configure>
参考 http://stackoverflow.com/questions/3861455/form-too-large-exception
review
Comments