【Spring】java.lang.IndexOutOfBoundsException: Index: 256, Size: 256
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的更多相关文章
- 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 ...
- exception java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
1.情景展示 Java 报错信息如下: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 2.原因分析 首先,这是越界异常,但不是数组越 ...
- java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 错误
你的ArrayList 是一个没有值的对象(不是null),也就是里面什么对象也没有存(即:arrayList.size()==0).但是,你有取它下标为0值的操作.所以,数组越界了!!比如array ...
- java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
在往数据库添加数据需要判断数据库中是否已有记录,判断的返回结果通常是List.在List为空的情况下,调用其方法需要格外注意,例如:调用get()则会报下标越界的异常. 当然还可以联想到其他情况,当判 ...
- Spring的java.lang.IndexOutOfBoundsException: Remember that ordinal parameters are 1-based!异常处理方法
使用Spring提供的模板类HibernateDaoSupport,如果单纯的使用'命名参数'的形式编写HQL语句如: public class UserDaoImpl extends Hiberna ...
- 【转】java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
最近在配置最新的ssh(struts2.3.16.3+hibernate4.3.7+spring4.1.2)的时候遇到的这个错误提示,后来在网上找了半天都不能解决,虽然有个说法是model对象用这样@ ...
- 【异常】java.lang.NoClassDefFoundError: com/lowagie/text/pdf/PdfContentByte
异常信息: java.lang.NoClassDefFoundError: com/lowagie/text/pdf/PdfContentByte at com.star.sms.busines ...
- 【转】java.lang.ClassNotFoundException: org.springframework.context.event.GenericApplicationListener
http://www.cnblogs.com/softidea/p/6064091.html Caused by: java.lang.NoClassDefFoundError: org/spring ...
- 【转】java.lang.OutOfMemoryError: Java heap space的解决
原文地址:http://blog.sina.com.cn/s/blog_4b12778b0100v0bb.html Myeclipse下java.lang.OutOfMemoryError: Java ...
随机推荐
- ASP.NET获取网站根目录(路径)
摘自: http://blog.sina.com.cn/s/blog_7d0dcba60100vb7r.html 网站在服务器磁盘上的物理路径: HttpRuntime.AppDomainAppPat ...
- Axure 简单原型设计
简介 Axure RP是一个专业的快速原型设计工具.Axure(发音:Ack-sure),代表美国Axure公司:RP则是Rapid Prototyping(快速原型)的缩写. Axure RP是美国 ...
- 数据结构之---C语言实现线索二叉树
//线索二叉树,这里在二叉树的基础上增加了线索化 //杨鑫 #include <stdio.h> #include <stdlib.h> typedef char ElemTy ...
- 使用JTextArea示例
相对于JLabel显示提示文字,JTextArea有一个先天优势:文字可以拷贝出来.经过下面设置它也能在外观上和JLabel一致. 代码如下: JTextArea txtArea=new JTextA ...
- selenium-Getting Started
1.1. Simple Usage If you have installed Selenium Python bindings, you can start using it from Python ...
- vue vue-router 使用注意事项
1.$router和$route区别 this.$router 访问路由器,实现路由的跳转等功能. this.$route 实现访问当前路由,$route.query (如果 URL 中有查询参数). ...
- PHP使用file_put_contents写入文件的优点
本篇文章由:http://xinpure.com/advantages-of-php-file-write-put-contents-to-a-file/ 写入方法的比较 先来看看使用 fwrite ...
- SQL&EF优化第一篇 各种情况下的性能测试之count函数篇
测试环境 mssql 08 +win7 数据 30W条 二〇一六年十月二十九日 09:04:43 结论:1>主键> *>可空列 推测未论证: 根据情况优先选择 顺便提 ...
- 扩展方法 DataTable的ToList<T>
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.T ...
- 数据结构(逻辑结构,物理结构,特点) C#多线程编程的同步也线程安全 C#多线程编程笔记 String 与 StringBuilder (StringBuffer) 数据结构与算法-初体验(极客专栏)
数据结构(逻辑结构,物理结构,特点) 一.数据的逻辑结构:指反映数据元素之间的逻辑关系的数据结构,其中的逻辑关系是指数据元素之间的前后件关系,而与他们在计算机中的存储位置无关.逻辑结构包括: 集合 数 ...