一个小问题,捣鼓了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
在高版本的tomcat中是-1
本文由 admin 创作,采用 知识共享署名4.0
国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:2022-08-09 22:53:32