長字串java後臺接收有時為空
阿新 • • 發佈:2019-01-04
這個問題原以為是後臺程式碼寫的有問題,查了一下發現是前臺傳的字串過長,tomcat的server.xml中Connector沒有新增配置屬性maxPostSize,然後預設的長度為2097152 (2 megabytes),請求內容過大超過了tomcat的預設值,只需把maxPostSize="-1"加上就行,這裡是負數代表沒有限制大小,網上有些人說是0也是沒有限制大小,查閱資料後發現是tomcat版本不同,所以配置的值不一樣。
tomcat7.0.63之前:
maxPostSize | The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes). |
設定為0和負數均可以代表不限制
tomcat7.0.63(包含)之後:
maxPostSize | The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than zero. If not specified, this attribute is set to 2097152 (2 megabytes). |
不可以設定為0,只能是負數代表不限制
CSDN 原文連線:https://blog.csdn.net/whatever8975757/article/details/60576188