Java spring MVC中的索引越界

Java spring MVC中的索引越界,java,spring,jsp,spring-mvc,Java,Spring,Jsp,Spring Mvc,我有一个bean AgreegateBean,我使用它作为传输对象。bean的类定义如下- Class AgreegateBean { private SomeOtherBean bean; private List<Person> someList; // getters and setters } 这是因为检索到的列表someList中没有元素 在以下情况之前检查: <c:if test="${someList != null}"> <inp

我有一个bean AgreegateBean,我使用它作为传输对象。bean的类定义如下-

Class AgreegateBean {

 private SomeOtherBean bean;
 private List<Person> someList;

 // getters and setters
}

这是因为检索到的
列表someList中没有元素

在以下情况之前检查:

<c:if test="${someList != null}">
    <input type="text" name="someList[0].name" />
    <input type="text" name="someList[0].surName" />
</c:if>


找到了解决方案。没有在getter和setter中使用泛型。不知道怎么做,但添加泛型可以解决问题。

我认为这不是问题所在,因为OP提到“提交”表单。我认为这更像是Spring,不创建
Person
的新实例。
org.springframework.beans.InvalidPropertyException: Invalid property 'someList[0]' of bean class [com.form.bean.AgreegateBean]: Index of out of bounds in property path 'someList[0]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
<c:if test="${someList != null}">
    <input type="text" name="someList[0].name" />
    <input type="text" name="someList[0].surName" />
</c:if>