转载自: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出现如下异常:的更多相关文章

  1. 【Spring】java.lang.IndexOutOfBoundsException: Index: 256, Size: 256

    Spring接受前台的数据超过256出现例如以下异常: org.springframework.beans.InvalidPropertyException: Invalid property 'sp ...

  2. nodejs 中 接受前端的数据请求的处理

    前台 ---->  后台 后台要接受 前台的数据,只能通过 http 但是 前台接受 后台的数据有  from   ajax    jsonp nodejs 给我们提供了模块 url 模块,可以 ...

  3. spring mvc 接受前台json @RequestBody json 属性 空 使用 JsonProperty spring mvc 获取json转乘bean

    请给json序列序列化成的javabean 属性加上   @JsonProperty(value = "real_name")   否则 springmvc 可能接受不到数据 ja ...

  4. springmvc对象映射个数超过256个

    /** 由于Spring在接受前台传入的List时,就会出现256的IndexOutOfBoundsException异常 设置setAutoGrowCollectionLimit为1024 @par ...

  5. 【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 ...

  6. 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 ...

  7. 使用Spring Data JPA进行数据分页与排序

    一.导读 如果一次性加载成千上万的列表数据,在网页上显示将十分的耗时,用户体验不好.所以处理较大数据查询结果展现的时候,分页查询是必不可少的.分页查询必然伴随着一定的排序规则,否则分页数据的状态很难控 ...

  8. Spring MVC3返回JSON数据中文乱码问题解决(转)

    Spring MVC3返回JSON数据中文乱码问题解决 查了下网上的一些资料,感觉比较复杂,这里,我这几使用两种很简单的办法解决了中文乱码问题. Spring版本:3.2.2.RELEASE Jack ...

  9. Stack的三种含义(数据超过栈的大小,就发生stack overflow)

    非常典型的基础知识,转自http://www.ruanyifeng.com/blog/2013/11/stack.html 学习编程的时候,经常会看到stack这个词,它的中文名字叫做"栈& ...

随机推荐

  1. git branch 命令

    1.git init 该命令执行之后并没有创建branch 2.git add 添加文件,这时branch 也还没生成.git branch name也没用 3.git commit 提交到git r ...

  2. MTK 隐藏上方的状态栏

    步骤一: 源码/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.ja ...

  3. 兼容 iOS Retina(视网膜显示) 的程序

    首先我们需要明确一点,iOS设备上图片兼容retina的问题最初是由于iPhone4的分辨率由iPhone3的320X480提升到了640X960所产生. 为了让iPhone4能够兼容iPhone3上 ...

  4. flexbox父盒子justify-content属性

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. Nginx(七)-- 反向代理

    1.概念  反向代理(Reverse Proxy)方式是指以代理服务器来接受Internet上的连接请求,然后将请求转发给内部网络上的服务器:并将从服务器上得到的结果返回给Internet上请求连接的 ...

  6. MongoDB 数据管理

    MongoDB 相关操作: > db.version() // 查看 MongoDB 版本 > db.serverStatus() // 查看 MongoDB 服务器的状态 MongoDB ...

  7. C#编码习惯谈

    1.  避免将多个类放在一个文件里面.2.  一个文件应该只有一个命名空间,避免将多个命名空间放在同一个文件里面.3.  一个文件最好不要超过500行的代码(不包括机器产生的代码).4.  一个方法的 ...

  8. BugHD 与你的应用一起成长

    BugHD 新增功能 1.新增安装量.启动量的统计功能 BugHD SDK 1.3.0新增安装量.启动量的统计功能,在崩溃分析页面右上角可看到安装量和启动量. BugHD 体验优化 1.Android ...

  9. [XPath] XPath 与 lxml (二)XPath 语法

    XPath 选取节点时使用的表达式是一种路径表达式.节点是通过路径(path)或者步(steps)来选取的. 本章使用以下 XML 文档作为示例. <?xml version="1.0 ...

  10. c语言指针笔记

    一.int a[20]1. 数组名代表数组首元素的地址,不代表数组的地址2. 对数组名取地址代表整个数组的地址.a和&a代表的数据类型不一样 a代表数组首元素的地址 &a数组类型 in ...