Spring MVC POST 参数无法绑定
2017-03-13 21:24
423 查看
Spring MVC 控制器,方法的参数突然绑定不上。
查看了相关的资料:这里、这里,都是说与 Content-Type 属性有关。
但从代码看,一切正常,并没有网上描述的情况。
换了一台电脑后,发现一切又恢复正常。想到最近优化过 Tomcat 。于是
最终确定问题的原因是 Tomcat 优化参数
其中问题是在
当去掉时,一切正常。
Tomcat 官方介绍
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).
大致意思是:maxPostSize 表示 post 参数的最大限制。如果设置为 0 或者 <0 则表示没有限制。
但是为什么设置为 0 时候,就没有办法传递参数了呢?
后来找到了 stackoverflow 上的一段说明:maxPostSize in tomcat’s configuration
The docs aren’t quite right. maxPostSize=0 results in a limit of zero. -1 is the correct value for no limit. I’ll get that fixed shortly.
大致意思:maxPostSize=0 导致 post 可传递的大小限制为 0 。正确表示没有限制应该设置为 -1 。
至此,应该是某些版本的 Tomcat 有此 Bug。至少确认 tomcat 8.5.11 有此问题。
maxPostSize 如果想要设置,可以设置为 -1。避免出现问题。
查看了相关的资料:这里、这里,都是说与 Content-Type 属性有关。
但从代码看,一切正常,并没有网上描述的情况。
换了一台电脑后,发现一切又恢复正常。想到最近优化过 Tomcat 。于是
最终确定问题的原因是 Tomcat 优化参数
<Connector port="8080" maxPostSize="0" .... />
其中问题是在
maxPostSize="0"上。
当去掉时,一切正常。
Tomcat 官方介绍
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).
大致意思是:maxPostSize 表示 post 参数的最大限制。如果设置为 0 或者 <0 则表示没有限制。
但是为什么设置为 0 时候,就没有办法传递参数了呢?
后来找到了 stackoverflow 上的一段说明:maxPostSize in tomcat’s configuration
The docs aren’t quite right. maxPostSize=0 results in a limit of zero. -1 is the correct value for no limit. I’ll get that fixed shortly.
大致意思:maxPostSize=0 导致 post 可传递的大小限制为 0 。正确表示没有限制应该设置为 -1 。
至此,应该是某些版本的 Tomcat 有此 Bug。至少确认 tomcat 8.5.11 有此问题。
maxPostSize 如果想要设置,可以设置为 -1。避免出现问题。
相关文章推荐
- spring mvc 服务端接收httpclient post 参数无法接收问题
- Spring MVC无法获取ajax POST的参数和值
- Spring MVC无法获取ajax POST的参数和值
- WebApi Post 后台无法获取参数的解决方案
- spring mvc参数绑定
- Spring MVC 4.0下参数绑定(List类型的参数)
- 无法绑定到新的显示成员,参数名:newDisplayMember
- spring mvc参数绑定大全
- spring mvc 结合easyui datagrid 使用responseBody 注解 返回json 无法绑定
- [Spring MVC] - SpringMVC的各种参数绑定方式
- Spring MVC无法获取到页面表单put过来的参数的解决方案
- spring mvc的数据绑定(参数绑定)
- jquery.post的参数在服务端无法接收 by Ardge
- Spring MVC 不同对象的同名参数绑定
- webapi 在POST时的坑以及OracleCommand的参数绑定的坑
- [读书笔记] Spring MVC中的参数绑定
- Spring MVC 使用ajax时,控制器无法获取客户端参数
- Spring MVC对象绑定时参数不能为空
- Spring MVC form 绑定,post 数据为空
- HttpWatch导致的ajax post 服务器无法猎取参数