zoukankan      html  css  js  c++  java
  • tomcat中间件提交表单数据量过大警告处理方案

    http://www.bubuko.com/infodetail-976418.html

    http://www.cnblogs.com/yg_zhang/p/4248061.html

    tomcat中间件提交表单数据量过大警告处理方案

    时间:2015-07-16 22:35:19      阅读:1348      评论:0      收藏:0      [点我收藏+]

    标签:instead   maximum number   中间件   000])   more than the maximum number of request parameters (get plus post) for a single request ([10   

    昨天系统出现了一个比较奇怪的BUG,表单提交后,数据没有全部执行。

    查看tomcat日志发现有以下警告:

    18:52:23,058  WARN HttpMethodBase:682 - Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.

    18:52:31,290  WARN HttpMethodBase:682 - Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.

    18:52:36,233  WARN HttpMethodBase:682 - Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.

    Jul 15, 2015 6:53:10 PM org.apache.tomcat.util.http.Parameters processParameters

    INFO: 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.

    查询相关资料后,发现是因为tomcat有提交参数的限制。

    修改tomcat  conf/server.xml文件,添加:

    <Connector executor="tomcatThreadPool"

    port="9080"

    protocol="HTTP/1.1"

    maxParameterCount="-1"

    connectionTimeout="20000"

    URIEncoding="UTF-8" />

    ########################################################################################################################

    在流程审批过程中,提交审批时发现使用request.getParameter(“taskId”)获取数据时,发现取得任务ID为空。

    在调试的过程中我发现表单的数据量特别大。

    到网上查询了一下,说post  提交数据数据量有限制。

    于是写了个表单测试了一下:

    复制代码
    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
    <%
        String taskId=request.getParameter("taskId");
        String name=request.getParameter("name");
        System.out.println(taskId);
        
        System.out.println(name);
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <body>
    <form name="frmSubmit" method="post">
    <input type="text" name="taskId">
    <textarea rows="30" cols="200" name="name"></textarea>
    <input type="submit" value="submit">
    </form>
    </body>
    </html>
    复制代码

    测试结果是,如果数据超过2MB的时候数据时获取不到了。是两个表单都获取不到数据,然后修改tomcat 连接参数。

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

    将maxPostSize修改为0则不显示post数据大小。

    发现还是没有解决之前的问题。

    在调试的过程中发现,服务器打印了如下信息。

    信息: 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.

    搜索了一下这个告警信息。

    原来是服务器对提交的参数做了限制,tomcat 文档描述如下:

    The maximum number of parameters (GET plus POST) which will be automatically parsed by the container. A value of less than 0 means no limit. If not specified, a default of 10000 is used. Note that FailedRequestFilter filter can be used to reject requests that hit the limit.

    这个默认值为10000个,如果超过了10000个那么就丢弃。这也就解释了为什么我把taskId提前到form标签后,数据能够获取到。

    知道了 原因:

    我们修改tomcat配置如下:

    <Connector maxParameterCount="-1"  maxPostSize="0" URIEncoding="utf-8" connectionTimeout="20000"  port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

    不限制参数大小和提交数据大小,这样重新审批就没有问题了。

    当然这个解决办法不是很好,因为他会极大的消耗服务器性能,因为提交的参数超过了10000个。

    解决的办法是不提交那么的表单,这个我们这个表单系统中是可以的。

    因为我们没有必要提交那么多的参数,我们的数据都拼装成了一个json进行提交,这样对服务器性能会 有极大的提升。

    将我们的程序修改成使用ajaxpost的方式提交,只提交部分参数就可以了。

  • 相关阅读:
    跃迁方法论 Continuous practice
    EPI online zoom session 面试算法基础知识直播分享
    台州 OJ 2648 小希的迷宫
    洛谷 P1074 靶形数独
    洛谷 P1433 DP 状态压缩
    台州 OJ FatMouse and Cheese 深搜 记忆化搜索
    台州 OJ 2676 Tree of Tree 树状 DP
    台州 OJ 2537 Charlie's Change 多重背包 二进制优化 路径记录
    台州 OJ 2378 Tug of War
    台州 OJ 2850 Key Task BFS
  • 原文地址:https://www.cnblogs.com/lteal/p/7238283.html
Copyright © 2011-2022 走看看