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这个词,它的中文名字叫做"栈& ...
随机推荐
- linux下.so、.ko、.a的区别
各类文件的区别与作用: 1.对于.so文件 .so文件是用户层的动态链接库,用于用户层的动态链接使用,内核态的代码同样不能直接访问. 2.对于.ko文件 .ko文件是内核态的动态链接库,用于内核态的动 ...
- HTML5标签canvas图像处理
摘要: canvas可以读取图片后,使用drawImage方法在画布内进行重绘.本文介绍canvas的图像处理 drawImage drawImage() 方法在画布上绘制图像.画布或视频.drawI ...
- Git学习笔记(三)
Git提交相关内容 在Git提交时,会保存一个提交对象,该对象包括一个指向暂存区内容快照的指针,包括本次提交作者等相关附属信息,包括零个或多个指向该提交对象的父对象指针:首次提交时是没有祖先,普通提交 ...
- Linux+Redis实战教程_day02_消息订阅与发布_多数据库_redis批量操作-事务_redis持久化
5.扩展知识-消息订阅与发布(了解) 订阅新闻,新闻发布 subscribe channel:订阅频道,例:subscribe mychat,订阅mychat这个频道 psubscribe chann ...
- System.exit(0)会跳过finally块的执行
public class test { public static void main(String[] args) { try { System.exit(0); System.out.printl ...
- Excel导出到浏览器(个人备份)
/// <summary> /// Excel导出 /// </summary> /// <param name="dt"></pa ...
- VMware按装ISO
破解码 vmware12 5A02H-AU243-TZJ49-GTC7K-3C61N vmware14CG54H-D8D0H-H8DHY-C6X7X-N2KG6 创建虚拟机 也可以选第三个直接选择Ce ...
- phpStorm中使用xdebug断点调试php代码
配置好xdebug,也能使得phpstorm像java哪像跑断点调试,爽的一笔!!! 下载xdebug并配置 [XDebug] zend_extension=php_xdebug-2.4.0rc3-5 ...
- 教你在windows下安装使用配置vim+gcc[转]
转自http://blog.163.com/lixiangqiu_9202/blog/static/535750372012461190722/ 一直在使用linux,但有时也会去虚拟机里的winxp ...
- 【存储过程】用SQL语句获得一个存储过程返回的表
定义一个存储过程如下: create proc [dbo].[test1] @id int as select 1 as id,'abc' as name union all select @id a ...