我想做这样的事情,其中foo是一个带有一个String字段名的类,以及getter/setter:
<form:form id="frmFoo" modelAttribute="foos">
<c:forEach items="${foos}" var="foo">
<form:input path="${foo.name}" type="text"/>
Run Code Online (Sandbox Code Playgroud)
然后提交更新名称的Foos完整列表?我的控制器sig看起来像这样:
@RequestMapping(value = "/FOO", method = RequestMethod.POST)
public String getSendEmail(List<Foo> foos, Model model) {
// ...
}
Run Code Online (Sandbox Code Playgroud) 我的视图中有一个将对象发送到控制器的表单,但是问题是,如果我发送的对象超过256个,则会出现异常:
org.springframework.beans.InvalidPropertyException: Invalid property 'followers[256]' of bean class [org.myec3.portalgen.plugins.newsletter.dto.FollowerFileDto]: Index of out of bounds in property path 'followers[256]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256
Run Code Online (Sandbox Code Playgroud)
所以我想知道为什么会有这样的限制,所以我找到了这个主题:https : //stackoverflow.com/a/24699008/4173394
但这似乎对我不起作用(可能是我的不当使用)。
这是我的结构:我的视图称为createUpdate.vm,并像这样发布我的表单:
<form id="createFollowerFileForm" method="post" action="#route("followerFileController.upsertFollowerFile")" enctype="multipart/form-data" class="form_styled">
Run Code Online (Sandbox Code Playgroud)
我的函数upsertFollowerFile在FollowerFileController中:
@InitBinder
public void initBinder(WebDataBinder dataBinder) {
// this will allow 500 size of array.
dataBinder.setAutoGrowCollectionLimit(500);
}
@Secured({ "ROLE_SUPER_ADMIN_PORTALGEN", "ROLE_CUSTOMER_PORTALGEN", "ROLE_ADMIN_PORTALGEN", "ROLE_WRITER_PORTALGEN" })
public String upsertFollowerFile(
@ModelAttribute(value = "followerFile") FollowerFileDto followerFileDto,
BindingResult result, ModelMap model, HttpServletRequest request) {
Run Code Online (Sandbox Code Playgroud)
和我的类FollowerFileDto:
public class FollowerFileDto …Run Code Online (Sandbox Code Playgroud)