背景
前端form表單傳值,後端用bean接收,
其中一個參數是所選城市id,前端通過數組傳遞,後端bean中使用list接收,當所選城市過多時,異常日誌報IndexOutOfBounds,索引256越界
原因
springmvc DataBinder默認collection大小爲256
解決
使用@InitBinder註解,初始化WebDataBinder,WebDataBinder繼承自DataBinder
@InitBinder
public void initBinder(WebDataBinder binder) {
int size=1000;//自定義size
binder.setAutoGrowCollectionLimit(size);
}