Jboss, Tomcat form submission data loss problem

refer to:

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

https://my.oschina.net/luckyi/blog/213209

https://developer.jboss.org/thread/177942

https://developer.jboss.org/thread/198502

 

To summarize the Jboss6 configuration:

 

need to set logging level of org.apache.catalina to DEBUG, then you will see the following line during the reproduction of the defect.

 

20:10:52,456 DEBUG [org.apache.catalina.connector] (http-/0.0.0.0:8080-6) JBWEB001023: 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.

 

standalone.xml

 

 Set the size of the entire form, if the setting is too large, there is a risk of being attacked

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" max-post-size="2147483647" max-save-post-size="2147483647" />
    <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true" max-post-size="2147483647" max-save-post-size="2147483647">
        <ssl name="ssl" key-alias="company" password="12345" certificate-key-file="${jboss.server.config.dir}/ssl.keystore" />
    </connector>
    <virtual-server name="default-host" enable-welcome-root="false">
        <alias name="localhost"/>
        <alias name="example.com"/>
    </virtual-server>
</subsystem>
   Set the number of fields when the form is submitted
<system-properties>
     <property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="5000"/>
</system-properties>
 

 

 -----------------------------------------------------------------------------------------------------------------------------------

 

During the process approval process, when submitting the approval, it is found that the task ID is empty when request.getParameter("taskId") is used to obtain data.

In the process of debugging, I found that the data volume of the form is particularly large.

I checked online and said that the amount of data submitted by post is limited.

 

So I wrote a form to test it:

copy code
<%@ 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>
copy code

The test result is that if the data exceeds 2MB, the data cannot be obtained. It is because the two forms cannot get the data, and then modify the tomcat connection parameters.

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

Modify maxPostSize to 0 to not display the post data size.

It is found that the previous problem has not been solved.

During the debugging process, it was found that the server printed the following information.

 

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

 

 

Search for this warning message.

原来是服务器对提交的参数做了限制,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"/>

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

 

Of course, this solution is not very good, because it will greatly consume server performance, because more than 10,000 parameters are submitted.

The solution is not to submit such a form, which is possible in our form system.

Because we don't need to submit so many parameters, our data is assembled into a json for submission, which will greatly improve the server performance.

Modify our program to use ajaxpost to submit, and only submit some parameters.

 

Jboss as7 org.apache.tomcat.util.http.Parameters.MAX_COUNT defaults to 512

In standalone.xml add the following lines

 

 

<system-properties>

     <property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="5000"/>

</system-properties>

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326614807&siteId=291194637