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

反编译的源代码例如以下:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

解决例如以下:重set下autoGrowCollectionLimit,当做绑定的时候set为1024或者更大

  /**
* 因为Spring在接受前台传入的List时,就会出现256的IndexOutOfBoundsException异常
* 设置setAutoGrowCollectionLimit为1024
* @param binder
* @see [类、类#方法、类#成员]
*/
@InitBinder
public void initListBinder(WebDataBinder binder)
{
// 设置须要包裹的元素个数,默觉得256
binder.setAutoGrowCollectionLimit(1024);
}

【Spring】java.lang.IndexOutOfBoundsException: Index: 256, Size: 256的更多相关文章

  1. hive脚本出现Error: java.lang.RuntimeException: Error in configuring object和Caused by: java.lang.IndexOutOfBoundsException: Index: 9, Size: 9

    是在reduce阶段报的错误,详细错误信息是 朱传豪 19:04:48 Diagnostic Messages for this Task: Error: java.lang.RuntimeExcep ...

  2. exception java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

      1.情景展示 Java 报错信息如下: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 2.原因分析 首先,这是越界异常,但不是数组越 ...

  3. java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 错误

    你的ArrayList 是一个没有值的对象(不是null),也就是里面什么对象也没有存(即:arrayList.size()==0).但是,你有取它下标为0值的操作.所以,数组越界了!!比如array ...

  4. java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

    在往数据库添加数据需要判断数据库中是否已有记录,判断的返回结果通常是List.在List为空的情况下,调用其方法需要格外注意,例如:调用get()则会报下标越界的异常. 当然还可以联想到其他情况,当判 ...

  5. Spring的java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!异常处理方法

    使用Spring提供的模板类HibernateDaoSupport,如果单纯的使用'命名参数'的形式编写HQL语句如: public class UserDaoImpl extends Hiberna ...

  6. 【转】java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;

    最近在配置最新的ssh(struts2.3.16.3+hibernate4.3.7+spring4.1.2)的时候遇到的这个错误提示,后来在网上找了半天都不能解决,虽然有个说法是model对象用这样@ ...

  7. 【异常】java.lang.NoClassDefFoundError: com/lowagie/text/pdf/PdfContentByte

    异常信息:   java.lang.NoClassDefFoundError: com/lowagie/text/pdf/PdfContentByte  at com.star.sms.busines ...

  8. 【转】java.lang.ClassNotFoundException: org.springframework.context.event.GenericApplicationListener

    http://www.cnblogs.com/softidea/p/6064091.html Caused by: java.lang.NoClassDefFoundError: org/spring ...

  9. 【转】java.lang.OutOfMemoryError: Java heap space的解决

    原文地址:http://blog.sina.com.cn/s/blog_4b12778b0100v0bb.html Myeclipse下java.lang.OutOfMemoryError: Java ...

随机推荐

  1. linux下使用C++ Json库

    安装Json库 1.下载JsonCpphttp://sourceforge.net/projects/jsoncpp/files/ 2.下载sconshttp://sourceforge.net/pr ...

  2. Ubuntu中Git服务器搭建

    git服务器搭建过程 参考网上资料搭建git服务器过程记录 如下: 需求 硬件需求:一台Ubuntu或者debian电脑(虚拟机),能通过网络访问到. 软件需求:git-core, gitosis, ...

  3. python wheel 包命名规则和 abi 兼容

    wheel 包的命名规定 wheel 包的命名格式为 {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform ...

  4. IIS漏洞过滤

    IIS漏洞报告会提示网站HEAD包含Server版本信息导致版本泄漏,看起来不是大问题的漏洞却被分到中危或高危的行列中, 因为攻击者可能使用被披露信息获取特定版本发现的安全漏洞以及利用程序. 下面提供 ...

  5. 拓扑排序的实现_TopoSort

    拓扑排序是求一个AOV网(顶点代表活动, 各条边表示活动之间的率先关系的有向图)中各活动的一个拓扑序列的运算, 可用于測试AOV 网络的可行性. 整个算法包含三步: 1.计算每一个顶点的入度, 存入I ...

  6. 解决RegexKitLite编译报错

    原地址:http://blog.csdn.net/kepoon/article/details/7586861 在编译RegexKitLite的时候,报错如下: Undefined symbols f ...

  7. 大并发server架构 && 大型站点架构演变

    server的三条要求: 高性能:对于大量请求,及时高速的响应 高可用:7*24 不间断,出现问题自己主动转移.这叫fail over(故障转移) 伸缩性:使用跨机器的通信(TCP) 另外不论什么网络 ...

  8. javascript-使用el表达式获取后台传递的数据

      js获取后台数据 CreateTime--2017年5月26日16:14:14Author:Marydon 在js中使用el表达式的前提是:HTML引用js使用内联方式(即在JSP页面内部使用js ...

  9. Excle中range的一些用法

    以下是一些range的简单用法 Sub aa() '-=============================================== '给B列设置填充颜色为黄色 Range(" ...

  10. Loadrunner socket协议lrs_receive函数接收到返回数据包 仍然等待服务器返回--解决

    前段时间在使用loadrunner socket协议发送数据包到到服务器,使用lrs_receive接收服务器应答数据包,已经接收到数据包,但LR仍然在等待服务器端返回,而且日志打印显示每次接收返回都 ...