Spring AutoPopulatingList最大大小? [英] Spring AutoPopulatingList max size?

查看:485
本文介绍了Spring AutoPopulatingList最大大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到Spring AutoPopulatingList的问题。我的用例如下:管理可以访问应用程序的用户列表。

I have a problem with the Spring AutoPopulatingList. My use case is the following : manage the list of users that can access an application.

在GUI端,我使用自动填充字段来搜索并将用户添加到右边的桌子。用户也可以从表中删除。
当GUI用户提交时,GUI动态地为用户构建一个包含字段的表单:selectedUsers [1],...,selectedUsers [N]。

On the GUI side, I use an autocomplete field to search and add users to a table on the right. Users can also be removed from the table. When the GUI user submits, the GUI dynamically builds a form with fields for the users : selectedUsers[1], ..., selectedUsers[N].

我的问题是我的支持bean中的AutoPopulatingList似乎只增长到256个项目,然后停止。所以我收到以下错误:

My problem is that the AutoPopulatingList in my "backing" bean seems to grow only to 256 items, and then stops. So I get the following error :

[myapp.web.controller.admin.form.ApplicationForm]:属性路径'selectedUsers [256]'中的列表索引无效;嵌套异常是java.lang.IndexOutOfBoundsException:索引:256,大小:256

[myapp.web.controller.admin.form.ApplicationForm]: Invalid list index in property path 'selectedUsers[256]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256

你知道是否有实际限制吗?如果是,有没有办法提高它?
如果没有,你能想到解决这个问题的方法吗?

Do you know if there is the actual limit ? If it is, is there a way to raise it ? If not, can you think of a workaround for this problem ?

预先感谢您的帮助

推荐答案

好的,所以我在Spring的内部挖掘了一些,发现默认情况下,256是限制。

Ok, so I dug a little more into Spring's internals and found that by default, 256 is the limit.

限制由BeanWrapperImpl#autoGrowCollectionLimit属性给出。 Spring的WebDataBinder默认配置将其设置为256。

The limit is given by the BeanWrapperImpl#autoGrowCollectionLimit attribute. Spring's WebDataBinder default configuration sets this to 256.

提高此限制的正确方法是在控制器中定义@InitBinder注释方法:

The proper way to raise this limit is to define a @InitBinder annotated method in your controller :

@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.setAutoGrowCollectionLimit(1024);
}

然后一切都按预期工作。

and then everything works as expected.

我没有尝试找到一种方法来全局修改此限制。

I did not try to find a way to modify this limit globally.

HTH

这篇关于Spring AutoPopulatingList最大大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆