转载自: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. symfony 事务提交

    1. 添加数据 新建一个对象,给对象赋值 $em = $this->getDoctrine()->getManager(); //添加事物 $em->getConnection()- ...

  2. js获取iframe里面的元素

    直接获取不行 var  win2 = document.querySelector('iframe[width = "1280" ]').contentWindow; var lo ...

  3. 开启apache的server-status辅助分析工具

    在Apache的调优过程中,可以通过查看Apache提供的server-status(状态报告)来验证当前所设置数值是否合理,在httpd.conf文件中做如下设置来打开: #加载mod_status ...

  4. 8 -- 深入使用Spring -- 4...5 AOP代理:基于注解的“零配置”方式

    8.4.5 基于注解的“零配置”方式 AspectJ允许使用注解定义切面.切入点和增强处理,而Spring框架则可识别并根据这些注解来生成AOP代理.Spring只是使用了和AspectJ 5 一样的 ...

  5. 【GIS】GDAL Python 影像裁剪

    # -*- coding: utf-8 -*- """ Created on Fri Nov 30 11:45:03 2018 @author: Administrato ...

  6. iOS开发-VFL初窥

    VFL是苹果为了简化Autolayout的编码而推出的抽象语言,在上一篇博客中我们发现如果使用NSLayoutConstraint来添加约束是非常繁琐的. 一个简单的Frame需要添加四个NSLayo ...

  7. 【重要】攻击动作时间段判断~使用动画time比较动画length和使用一个变量数组做延迟

    using UnityEngine; using System.Linq; using System.Collections.Generic; [RequireComponent(typeof(Cha ...

  8. hadoop自动提交脚本

    自动提交到hadoop系统,然后调用wordcount的任务,并下载输出的文件. #!/bin/sh #从给定的路径获取文件列表,提交到hadoop系统,使用wordcount的功能统计单词数量 #e ...

  9. PyQt4程序图标

    程序图标就是一个小图片,通常显示在程序图标的左上角(ubuntu gnome在最上侧). #!/usr/bin/python # -*- coding:utf-8 -*- import sys fro ...

  10. iOS - 栈顶VC控制器的获取

    iOS 获取当前顶层的ViewController #pragma mark - topVC - (UIViewController *)theTopviewControler { UIViewCon ...