HTTP POST 数据过大处理
deng_chaowang  • 7年前  • 50 次浏览  • Java团队  
package com.jcbase.conf


public void configConstant(Constants me) {
PropKit.use("a_little_config.txt"); // 加载少量必要配置,随后可用PropKit.get(...)获取值
me.setDevMode(PropKit.getBoolean("devMode", false));
me.setViewType(ViewType.JSP); // 设置视图类型为Jsp,否则默认为FreeMarker
me.setMaxPostSize(100*1024*1024);//最大支持 100M 文件上传
}


5个回复

deng_chaowang 7年前 1楼

System.setProperty("sun.net.client.defaultConnectTimeout", String
.valueOf(10000));// (单位:毫秒)

System.setProperty("sun.net.client.defaultReadTimeout", String
.valueOf(10000)); // (单位:毫秒)

//java.lang.IllegalStateException: Form too large 238351>200000 处理方法
System.setProperty("org.mortbay.jetty.Request.maxFormContentSize", "900000");


deng_chaowang 7年前 2楼

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<!-- 增加systemProperties属性 -->
<systemProperties>
<systemProperty>
<name>org.mortbay.jetty.Request.maxFormContentSize</name>
<!-- -1代表不作限制 -->
<value>-1</value>
</systemProperty>
</systemProperties>
<scanIntervalSeconds>1</scanIntervalSeconds>
<contextXml>${project.basedir}/src/main/resources/jetty-context.xml</contextXml>
<stopKey>stop</stopKey>
<stopPort>6634</stopPort>
<webAppConfig>
<defaultsDescriptor>src/main/resources/webdefault.xml</defaultsDescriptor>
<contextPath>/</contextPath>
</webAppConfig>
<scanIntervalSeconds>0</scanIntervalSeconds>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>9305</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
      <!-- 增加systemProperties属性 -->
<systemProperties>
<systemProperty>
<name>org.mortbay.jetty.Request.maxFormContentSize</name>
<!-- -1代表不作限制 -->
<value>-1</value>
</systemProperty>
</systemProperties>


deng_chaowang 7年前 4楼

client_max_body_size 80M;

client_body_buffer_size 12800k;


/usr/local/nginx


deng_chaowang 7年前 5楼

@Override
public void afterJFinalStart()
{
//java.lang.IllegalStateException: Form too large 238351>200000 get
if (JFinal.me().getServletContext().getClass().getName().equals("org.eclipse.jetty.webapp.WebAppContext$Context")) {
try {
ServletContext ctx = JFinal.me().getServletContext();
Method getContextHandler = ctx.getClass().getMethod("getContextHandler", null);
Object handler = getContextHandler.invoke(ctx, null);
Method setMax = handler.getClass().getMethod("setMaxFormContentSize", int.class);
setMax.invoke(handler, 1024 * 1024 * 100);
} catch (Exception e) {
e.printStackTrace();
}
}
}


回到顶部