"Spring" java.lang.indexoutofboundsexception:index:256, size:256

Source: Internet
Author: User
Tags form post

Spring receives more than 256 of the foreground data with the following exception:

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: 256org.springframework.beans.beanwrapperimpl.getpropertyvalue (beanwrapperimpl.java:811) Org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper (beanwrapperimpl.java:554)

Traced the code of Spring, found the DataBinder, first explain the role of the DataBinder class, see links

Http://docs.spring.io/spring/docs/1.2.x/api/org/springframework/validation/DataBinder.html

There is one sentence

Binder that allows-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 is potential security implications in failing to set a array of allowed fields. In the case of HTTP form POST data For example, malicious clients can attempt to subvert a application by supplying value s for fields or properties that does not exist on the form. In some cases this could leads to illegal data being set on command objects or their nested objects. For this reason, it's highly recommended to specify the Allowedfields property on the DataBinder.

Probably means that the foreground form element is bound to the background of the Javebean object, doing a mapping, but the list length of this map can not exceed 256

The source of the anti-compilation is as follows:




The fix is as follows: Autogrowcollectionlimit under Reset, set 1024 or greater when binding

  /**     * Due to spring's acceptance of the list at the foreground, a 256 indexoutofboundsexception exception will appear     * Set Setautogrowcollectionlimit to 1024x768     * @param Binder     * @see [Class, Class # method, Class # member]     *    /@InitBinder public    void Initlistbinder (Webdatabinder binder)    {        //Set the number of elements that need to be wrapped, default to        Binder.setautogrowcollectionlimit (1024x768);    }



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"Spring" java.lang.indexoutofboundsexception:index:256, size:256

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.