相关疑难解决方法(0)

使用spring 3 mvc列出<Foo>作为表单后备对象,语法是否正确?

我想做这样的事情,其中​​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)

spring jsp jstl spring-mvc

20
推荐指数
1
解决办法
3万
查看次数

从视图向控制器发送对象列表:最多256个对象

我的视图中有一个将对象发送到控制器的表单,但是问题是,如果我发送的对象超过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)

java post spring spring-mvc java-ee

5
推荐指数
1
解决办法
2217
查看次数

标签 统计

spring ×2

spring-mvc ×2

java ×1

java-ee ×1

jsp ×1

jstl ×1

post ×1