POST方法提交参数丢失问题

昨天在解决一个BUG时发现一个奇怪的问题,一个AJAX提交数据在之前都是木有问题的,突然提交出错影响其他处理流程。

检查时发现页面处理数据较多,起初以为是提交顺序不正确修改后发现不是由此问题引起。于是删除掉一部分数据进行提交,较少数据能够提交成功。

恢复较多数据后跟踪提交FORM DATA ,发现数据是存在的,同时后台也未报其他错误。

随后设置Tomcat中POST方式提交数据大小:

maxPostSize="0"

  修改后提交数据依然会出错,但给出了错误提示:

信息: More than the maximum number of request parameters (GET plus POST) for a single request ([10,000]) were detected. Any parameters beyond this limit have been ignored. To change this limit, set the maxParameterCount attribute on the Connector.

 Note: further occurrences of this error will be logged at DEBUG level.

按照错误提示在在Connector 节点中加入maxParameterCount="-1",再进行测试便成功了。

<Connector executor="tomcatThreadPool"

               port="9080"

               protocol="HTTP/1.1"

              maxParameterCount="-1"

               connectionTimeout="20000"

               acceptCount="75"

               disableUploadTimeout="true"

               enableLookups="false"

               URIEncoding="UTF-8" />


maxParameterCount

The maximum number of parameters (GET plus POST) which will be automatically parsed by the container. 10000 by default. A value of less than 0 means no limit.


查询网上资料了解到引起该问题是

由于Java中的哈希表实现上的漏洞,现如今因为Tomcat使用了哈希表来存储HTTP请求参数,因此也受此问题影响。

为此Tomcat实现了一个变通的做法,提供一个新的选项maxParameterCount用来限制但请求中最大的参数数量,该参数默认值是10000,这对多数应用程序来说已经足够,这个值也足够用来绕过JRE中的哈希表的bug。

如果你正在使用早期的Tomcat版本(Apache Tomcat 5.x,Apache Tomcat 6.x,Apache Tomcat 7.x),没有maxParameterCount属性,那么可以通过限制maxPostSize到10kb以下来解决这个问题。

也可以升级到5.5.35, 6.0.35或7.0.23及以上版本使用maxParameterCount属性进行处理

转载于:https://my.oschina.net/luckyi/blog/213209

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值