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这个词,它的中文名字叫做"栈& ...
随机推荐
- MyBatis 与 Spring 是如何结合在一起工作的——mybatis-spring(version:1.2.2)
在MyBatis-Spring的项目中,我们一般会为MyBatis配置两个配置文件 beans-mybatis.xml 和 mybatis-config.xml.其中 beans-mybatis.xm ...
- NYOJ 116 士兵杀敌 (线段树,区间和)
题目链接:NYOJ 116 士兵杀敌 士兵杀敌(二) 时间限制:1000 ms | 内存限制:65535 KB 难度:5 描写叙述 南将军手下有N个士兵,分别编号1到N,这些士兵的杀敌数都是已知的 ...
- Axis2发布服务,支持Tomcat和Weblogic的SSHWeb项目部署
先说下遇到的问题,在SSHWeb项目中使用JDK自带的jar发布WebService(Endpoint.publish),在tomcat下可以正常发布,但是在Weblogic报奇葩错误,如Struts ...
- HttpClinet学习笔记
本文为学习httpClient学习过程中转载的文章,若涉及版权请留言. ----------------------------- 前言 超文本传输协议(HTTP)也许是当今互联网上使用的最重要的协议 ...
- 启用sharepoin2013中的ChartWebPart
首先看一张sharepoint2013中ChartWebPart的效果图. 在sharepoint2010中加入了一个新的webpart,叫ChartWebPart,提供了对数据的图表展示,可以对数据 ...
- Android开发-- Genymotion模拟器
模拟器安装 http://blog.csdn.net/beiminglei/article/details/13776013 连接ADB http://android3g.diandian.com/p ...
- [Linux] 特殊文件 /dev/zero
/dev/zero 是类 Unix 系统中一个特殊的文件,当读取该文件时,它会提供无限的空字符 null.它的一个主要用途是提供字符流来初始化数据存储,也就是使用空字符覆盖目标数据.另一个常见的用法是 ...
- mybatis 之 parameterType="HashMap"参数包含list
/** * 获得人气组合商品详情 * @param paramMap * @return */ public List<Goods> getCheckGoodsCombination(Ma ...
- thinkjs 中增加过期时间
使用thinkjs搭建的项目需要实现一小时后过期的功能:于是对比了新建项目与原有项目的不同之处: 官网中给的介绍:https://thinkjs.org/zh-cn/doc/2.2/a ...
- no matching function for call to ‘std::basic_string<char>::assign(std::string&, int)
使用string中的assign赋值函数报错,代码为: text0.assign(line,i+); 其中text0与line都为string类型 最后发现assign函数的原型为 string &a ...