POST请求数据,出现Post too large...错误
来源:互联网 发布:淘宝网运动鞋 编辑:程序博客网 时间:2024/06/06 03:00
1.问题场景
java web开发当中,使用apache tomcat作为服务器,使用POST请求数据时,可能会出现:Post too large...的情况,错误信息:Parameters were not parsed because the size of the posted data was too big. Use the maxPostSize attribute of the connector to resolve this if the application should accept large POSTs.
2.问题原因
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.
3.解决办法
将maxPostSize参数值设置成0,或者删除这个属性即可。
4.问题延伸
(1).有些时候需要设置该参数值以达到使用tomcat拦截大数据请求的场景,但是设置maxPostSize属性值不成功的场景。
网上解释是:As I understand it, Tomcat only enforces that limit if the content type is application/x-www-form-urlencoded. For multiparts you'll have to read the stream yourself and enforce the limit yourself. A great tool for working with multipart data is Apache FileUpload.
即tomcat能够处理拦截的请求的contextType需要是application/x-www-form-urlencoded
(2).对于java中String字符串,
a.如果采用new Stirng()的形式创建String对象,那么限制的长度是Integer.MAX_VALUE = 2147483647 (差不多是4G)
解析原因:String对象在内存中是以字符数据的形式存在,那么创建一个字符数据:
char[] str = new char[Integer.MAX_VALUE]; // 可以看出字符数组的最大长度是Integer.MAX_VALUE
b.采用直接量创建String时,ASCII字符长度为65534个
解析原因:CONSTANT_Utf8_info表中使用一个16位的无符号整数来记录字符串的长度的,最多能表示 65536个字节,而java的.class文件是使用一种变体UTF-8格式来存放字符的,null值使用两个字节来表示,因此只剩下 65536 - 2 = 65534个字节。如果字符串中含有中文等非ASCII字符,那么双引号中字符的数量会更少(一个中文字符占用三个字节)。
String str = "abd...";
- POST请求数据,出现Post too large...错误
- Express 错误,请求数据太大,Payload Too Large
- django POST请求出现403错误
- form 提交 无法显示该网页 数据量大提交Post too large错误
- 使用fiddler更改post请求数据,具现post错误
- Django POST请求错误
- post请求 400错误
- 请求出现 Nginx 413 Request Entity Too Large错误的解决方法
- java.lang.IllegalStateException: Post too large异常及其解决办法
- http post request header is too large 问题
- http post request header is too large 解决方案
- 数据请求get post
- 12、post请求数据
- POST数据请求
- post请求数据
- HttpUrl --post请求数据
- HttpClient --post请求数据
- HttpUrl--post请求数据
- c语言输入年月日,判断是这一年的第几天
- Python读取xml
- Eclipse 支持jQuery 自动提示
- 安装ndnx
- WebView调用Javascript方法
- POST请求数据,出现Post too large...错误
- 嵌入式Linux文件系统简介
- 水晶头
- 热得快电路及分析
- linux环境下,关于系统自动安装eclipse时,其插件的安装方法
- Delphi_EnumWindows 的一个例子
- 开漏输出-开集输出
- C#中FileStream文件流详解
- Java运行应用程序,出现“Bad version”异常