长字符串java后台接收有时为空

     这个问题原以为是后台代码写的有问题,查了一下发现是前台传的字符串过长,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

猜你喜欢

转载自blog.csdn.net/DavidSoCool/article/details/82993170