springMVC接收值list时,超过256出现IndexOutOfBoundsException

原因

DataBinder类,接收参数中默认为256

public class DataBinder implements PropertyEditorRegistry, TypeConverter {

    /** Default object name used for binding: "target". */
    public static final String DEFAULT_OBJECT_NAME = "target";

    /** Default limit for array and collection growing: 256. */
    public static final int DEFAULT_AUTO_GROW_COLLECTION_LIMIT = 256;

解决方式

在需要的controller中加入如下方法

 @InitBinder  
    protected void initBinder(WebDataBinder binder) {  
        binder.setAutoGrowNestedPaths(true);  
        binder.setAutoGrowCollectionLimit(1024);  
    } 

 

posted @ 2021-02-03 14:54  也算知书识礼人  阅读(331)  评论(0编辑  收藏  举报