【Spring】java.lang.IndexOutOfBoundsException: Index: 256, Size: 256
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或者更大
- /**
- * 由於Spring在接受前臺傳入的List時,就會出現256的IndexOutOfBoundsException異常
- * 設定setAutoGrowCollectionLimit為1024
- * @param binder
- * @see [類、類#方法、類#成員]
- */
- @InitBinder
- public void initListBinder(WebDataBinder binder)
- {
- // 設定需要包裹的元素個數,預設為256
- binder.setAutoGrowCollectionLimit(1024);
- }
轉載:http://blog.csdn.net/Dracotianlong/article/details/47604723
相關文章
- java.lang.IndexOutOfBoundsException: Index: 0, Size: 0JavaIndexException
- Dependencies of Applications (256)APP
- 什麼是256位加密?加密
- Codeforces Round #256 (Div. 2)
- MACSHA256加密生成簽名Mac加密
- 解決yum [Errno 256] No more mirrors to try
- SHA256withRSA金鑰加簽
- 256種程式語言大薈萃
- 遊戲中用的256色顏色表遊戲
- delphi加密C#解密(AES-256)加密C#解密
- yum [Errno 256] No more mirrors to try 解決方法
- Codeforces Round #256 (Div. 2)A-D
- Milkv DUO 256 RNDIS 訪問外網
- Windows10系統如何設定256色Windows
- zabbix“專家坐診”第256期問答
- Oracle 11G OCP 1Z0-053 256Oracle
- Checking monitor:must be configured to display at least 256 colorsAST
- 加密演算法原理分析(MD5、SHA-256)加密演算法
- 什麼是安全雜湊演算法SHA256?演算法
- ORA-1652: unable to extend temp segment by 256 in tablespace PSAPTEMPAPT
- 「暑期訓練」「Brute Force」 Multiplication Table (CFR256D2D)
- 【JS 逆向百例】Ether Rock 空投介面 AES256 加密分析JS加密
- 取消RHAS3啟動時256M檢測(轉)S3
- keycloak~jwt的rs256簽名的驗證方式JWT
- Index column size too large. The maximum column size is 767 bytesIndex
- SHA-256加密簡單例項(客戶端、服務端)加密單例客戶端服務端
- 使用SHA256WithRSA來簽名和驗籤(.NET/C#)C#
- Index column size too large. The maximum column size is 767 bytes.Index
- 加密演算法比較:SHA1,SHA256,MD5加密演算法
- Windows自帶MD5 SHA1 SHA256命令列工具Windows命令列
- PostgreSQL 原始碼解讀(256)- PG 14(Improving connection scalability)#8SQL原始碼
- TABLE size (including table,index,lob,lobindex)Index
- iPhone 7與Plus震驚細節洩密 容量擴至256GBiPhone
- 1709 - Index column size too large. The maximum column size is 767 bytes.Index
- iPhone 6SE售價要狂漲 最低32GB/最高256GB!iPhone
- 【MySQL】5.6.x sha256_password外掛登入使用者時報錯MySql
- Oracle 12c redhat linux 6 安裝驗證錯誤at least 256 colorsOracleRedhatLinuxAST
- AIX 11gR2 grid root.sh Error: with status:FAIL.Error code is 256AIError