我有一個bean AgreegateBean,我正在使用它作爲傳輸對象。豆的類定義爲 -春季索引超出限制MVC
Class AgreegateBean {
private SomeOtherBean bean;
private List<Person> someList;
// getters and setters
}
我在使用ModelAttribute註釋的Spring控制器中使用此bean。對於JSP,我有JSTL。我用這樣的字段填充了JSP。
<input type="text" name="someList[0].name" />
<input type="text" name="someList[0].surName" />
當我提出我的形式我得到java.lang.IndexOutOfBoundsException:指數:0,大小:0。
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
我不認爲這是問題,因爲OP提到「提交」表單。我認爲這更多Spring並沒有創建'Person'的新實例。 – Tunaki