SPRINGMVC cannot exceed 256 values when submitting an array (GO)

Source: Internet
Author: User

The project encountered this error, and spring MVC has this vulnerability.

Org.springframework.beans.InvalidPropertyException:Invalid Property'detail[256]'of beansclass[Com.suning.asvp.mer.entity.InviteCooperationInfo]: Index of outof boundsinchProperty Path'detail[256]'; Nested exception isJava.lang.IndexOutOfBoundsException:Index: the, Size: theAt Org.springframework.beans.BeanWrapperImpl.getPropertyValue (Beanwrapperimpl.java:833) ~[spring-beans-3.1.2. Release.jar:3.1.2. RELEASE] at Org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper (Beanwrapperimpl.java:576) ~[spring-beans-3.1.2. Release.jar:3.1.2. RELEASE] at Org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath (Beanwrapperimpl.java:553) ~[spring-beans-3.1.2. Release.jar:3.1.2. RELEASE] at Org.springframework.beans.BeanWrapperImpl.setPropertyValue (Beanwrapperimpl.java:914) ~[spring-beans-3.1.2. Release.jar:3.1.2. RELEASE] at Org.springframework.beans.AbstractPropertyAccessor.setPropertyValues (Abstractpropertyaccessor.java:  the) ~[spring-beans-3.1.2. Release.jar:3.1.2. RELEASE] at Org.springframework.validation.DataBinder.applyPropertyValues (Databinder.java:692) ~[spring-context-3.1.2. Release.jar:3.1.2. RELEASE] at Org.springframework.validation.DataBinder.doBind (Databinder.java:588) ~[spring-context-3.1.2. Release.jar:3.1.2. RELEASE] at Org.springframework.web.bind.WebDataBinder.doBind (Webdatabinder.java:191) ~[spring-web-3.1.2. Release.jar:3.1.2. RELEASE] at Org.springframework.web.bind.ServletRequestDataBinder.bind (Servletrequestdatabinder.java: the) ~[spring-web-3.1.2. Release.jar:3.1.2. RELEASE]

Solution, override the Springmvc restriction array method in action:

  @InitBinder  public  void   Initbinder (Webdatabinder binder) { //  Set the maximum length of list  binder.setautogrowcollectionlimit (10000  ); }  
This code I found in the project in the resolution of the framework defects in the baseaction has already rewritten this method, in the other action is inherited baseaction, in the development environment testing is not a problem, but in the test environment is not effective, and finally think of two solutions ,  1. Directly in their action to rewrite the above method  2. Convert arrays into JSON strings at the foreground, To the background to convert the JSON string into a set scheme one: In fact, the above code is written in Baseaction in order to do not have to rewrite in the other action, but in the test environment does not take effect, very depressed, only this looks like the Scheme II: Json.stringifier ( MyObject); But to the background is an error, should be the existence of special characters scheme three: the development environment can be, test environment can not, will be other problems, so let the deployment of personnel to clear the deployment package cache, but still useless, may be the two environment differences it is finally solved with a solution, because the time is tight, the project is fast on the line, And if you change to a JSON string, the change point is more, and finally decided to use the scheme before the problem is not known, the work is a learning process

Original address: 50839218

SPRINGMVC cannot exceed 256 values when submitting an array (GO)

Related Article

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.