Spring接受前台的数据超过256出现如下异常:
转载自:http://blog.csdn.net/dracotianlong/article/details/47604723
Spring接受前台的数据超过256出现如下异常:
- org.springframework.beans.InvalidPropertyException: Invalid property 'specificationValues[256]' of bean class [com.sencloud.entity.Specification]: Index of out of bounds in property path 'specificationValues[256]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256
- org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:811)
- org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:554)
溯源了下Spring的代码,找到了DataBinder,先解释下DataBinder类的作用,见链接
http://docs.spring.io/spring/docs/1.2.x/api/org/springframework/validation/DataBinder.html
其中有一句
- Binder that allows for binding property values to a target object. The binding process can be customized through specifying allowed fields, required fields, and custom editors.
- Note that there are potential security implications in failing to set an array of allowed fields. In the case of HTTP form POST data for example, malicious clients can attempt to subvert an application by supplying values for fields or properties that do not exist on the form. In some cases this could lead to illegal data being set on command objects or their nested objects. For this reason, it is highly recommended to specify the allowedFields property on the DataBinder.
大概意思是前台的Form 元素绑定到 后台的JaveBean对象,做的一个映射,但是这个映射的List长度不可以超过256
反编译的源码如下:
解决如下:重set下autoGrowCollectionLimit,当做绑定的时候set为1024或者更大
- /**
- * 数据绑定
- *
- * @param binder
- * WebDataBinder
- */
- @InitBinder
- protected void initBinder(WebDataBinder binder) {
- binder.setAutoGrowCollectionLimit(2048);
- }
Spring接受前台的数据超过256出现如下异常:的更多相关文章
- 【Spring】java.lang.IndexOutOfBoundsException: Index: 256, Size: 256
Spring接受前台的数据超过256出现例如以下异常: org.springframework.beans.InvalidPropertyException: Invalid property 'sp ...
- nodejs 中 接受前端的数据请求的处理
前台 ----> 后台 后台要接受 前台的数据,只能通过 http 但是 前台接受 后台的数据有 from ajax jsonp nodejs 给我们提供了模块 url 模块,可以 ...
- spring mvc 接受前台json @RequestBody json 属性 空 使用 JsonProperty spring mvc 获取json转乘bean
请给json序列序列化成的javabean 属性加上 @JsonProperty(value = "real_name") 否则 springmvc 可能接受不到数据 ja ...
- springmvc对象映射个数超过256个
/** 由于Spring在接受前台传入的List时,就会出现256的IndexOutOfBoundsException异常 设置setAutoGrowCollectionLimit为1024 @par ...
- 【spring boot】spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [java.util.Date]
spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [jav ...
- ajax使用向Spring MVC发送JSON数据出现 org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported错误
ajax使用向Spring MVC发送JSON数据时,后端Controller在接受JSON数据时报org.springframework.web.HttpMediaTypeNotSupportedE ...
- 使用Spring Data JPA进行数据分页与排序
一.导读 如果一次性加载成千上万的列表数据,在网页上显示将十分的耗时,用户体验不好.所以处理较大数据查询结果展现的时候,分页查询是必不可少的.分页查询必然伴随着一定的排序规则,否则分页数据的状态很难控 ...
- Spring MVC3返回JSON数据中文乱码问题解决(转)
Spring MVC3返回JSON数据中文乱码问题解决 查了下网上的一些资料,感觉比较复杂,这里,我这几使用两种很简单的办法解决了中文乱码问题. Spring版本:3.2.2.RELEASE Jack ...
- Stack的三种含义(数据超过栈的大小,就发生stack overflow)
非常典型的基础知识,转自http://www.ruanyifeng.com/blog/2013/11/stack.html 学习编程的时候,经常会看到stack这个词,它的中文名字叫做"栈& ...
随机推荐
- mysql数据库中,如何对json数据类型的值进行修改?通过json_set函数对json字段值进行修改?
需求描述: 今天在看mysql中存放json数据类型的问题,对于json数据进行修改的操作, 在此记录下. 操作过程: 1.创建包含json数据类型的表,插入基础数据 mysql> create ...
- Nginx服务器之负载均衡策略
http://www.cnblogs.com/1214804270hacker/p/9325150.html
- less语法(二)混合属性
摘要: 前面介绍了less的变量和extend语法,今天在研究下混合属性(Mixin).混合可以说是less的另一个特征,你可以将通用属性定义在一块,然后使用时直接调用此混合属性. 混合: 在 LES ...
- 04-vi使用方法详细介绍
vi使用方法详细介绍 vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令.由于对Unix及Linux系统的任何版 ...
- vux 使用 loading 组件
1)声明引入Loading import { Loading } from 'vux' 2)在模版底部添加 组件(需要添加到 template>div 标签里) <template> ...
- React Native(十二)——嵌套WebView中的返回处理
情景描述: 从一个名为"My"的组件点击进去,进入一个列表(该列表内容为webView中内容),其中一个webView也可以点击进入详情页(也为webView),但是如果对导航栏不 ...
- 剑指offer面试题6:重建二叉树
1.题目:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树. public class Solution { public TreeNode reConstructBinaryTree(int ...
- 启用PAE后虚拟地址到物理地址的转换
34 注册:2013-10 帖子:2013 精华:34 --> [原创]启用PAE后虚拟地址到物理地址的转换 安于此生 2013-11-3 20:54 16073 由常规的两级页表转换得不到 ...
- 【cs229-Lecture14】主成分分析法
本节课内容: 因子分析 ---因子分析中的EM步骤的推导过程 主成份分析:有效地降低维度的方法 因子分析 混合高斯模型的问题 接下来讨论因子分析模型,在介绍因子分析模型之前,先看高斯分布的另一种写法, ...
- 安卓下junit测试
安卓下junit测试 第一种方法: 1,在AndroidManifest.xml下,加入如下红色代码 <manifest xmlns:android="http://schemas.a ...