Post大文本的情况下request.getParameter(fieldName)NULL的问题

/ 0条评论 / 0 个点赞 / 1205人阅读

一个小问题,捣鼓了2天,整个人都崩溃了。尤其是改了半天最后发现仅仅是一个简单的参数配置。。

我的需求是,通过ajax上传比较大的文本。之前程序在小文本环境下一切ok,换成大文本(4~5M)的时候,java的request.getParameter("fieldName")得到的都是null。十分不解,后来发现居然是Tomcat的配置问题,具体如下,修改后一切正常 2333333

根据官方文档http://tomcat.apache.org/tomcat-6.0-doc/config/http.html,我们可以看出,tomcat6在默认状态下最大的post请求是2M 

maxPostSize 

The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes). 


如果需要修改的,就需要找到server.xml文件 

<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443"  maxPostSize="0" />

maxPostSize: 0 表示不限制 

其中单位为:byte