Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http post提交内容过大导致后台获取参数值为null #7

Open
DimonHo opened this issue Sep 1, 2017 · 3 comments
Open

http post提交内容过大导致后台获取参数值为null #7

DimonHo opened this issue Sep 1, 2017 · 3 comments

Comments

@DimonHo
Copy link
Owner

DimonHo commented Sep 1, 2017

问题描述:

使用ajax,用Post向后台提交数据的时候,如果data太大,在后台获取data参数的时候会变成null。

问题分析:

POST请求本身并未限制传入参数大小,是tomcat 容器设置了接收参数大小的限制,默认限制为2097152bytes(2MB).

解决方法:

修改tomcat/conf/server.xml,在8080端口配置中加入maxPostSize="0"参数

<Connector port="8080" protocol="HTTP/1.1"   
  connectionTimeout="2000"   
  redirectPort="8443"   
  URIEncoding="UTF-8"  
  maxThreads="3000"  
  compression="on"
  maxPostSize="0"/>  

其中参数maxPostSize="10240"是限制post请求参数的大小,将值改为0代表不限制。
注意:maxPostSize参数只有当request的Content-Type为“application/x-www-form-urlencoded”时起作用。参考链接:http://stackoverflow.com/questions/7696197/tomcat-maxpostsize-value-ignored-with-xmlhttprequest

@wanglongbiao
Copy link

现在好像是改成0不行了,最大改成-1可以

@DimonHo
Copy link
Owner Author

DimonHo commented May 29, 2018

@wanglongbiao 请问你是用的哪个版本?

@wanglongbiao
Copy link

我查过资料了,Tomcat7 以后需要设置为 -1 才行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants