0
添加多個數組值它給了我一個錯誤,而在數據庫提交多個值 錯誤:IndexOutofBond如何Grails的
<form action="emp/forsubmit" method=" post">
<input id="emp[0].name" name="emp[0].name" type="text"/>
<input id="emp[0].lastname" name="emp[0].lastname" type="text"/>
<input id="emp[1].name" name="emp[1].name" type="text"/>
<input id="emp[1].lastname" name="emp[1].lastname" type="text"/>
</form>
我使用的MongoDB爲Db
控制器源代碼:
def update(){
if(empInstance.getEmp_history() == null || empInstance.getEmp_history().size() == 0) {
empInstance.setEmp_history(new ArrayList<EmpHistory>());
empInstance.getEmp_history().add(new EmploymentHistory());
}
empInstance.properties = params
}
它與[this]有何區別(http://stackoverflow.com/questions/17698011/how-to-add-array-object-in-grails-2-2-2)昨天發佈的問題? – dmahapatro
兩種形式都是相同的....在昨天的形式,我試圖直接提交數組的第二個對象「emp [1]」..這次我試圖提交兩個對象在同一時間「emp [0]和emp [1]「..但仍然給我同樣的錯誤 –
@ user2446714:提交表單不會導致數據庫錯誤。你應該顯示一些控制器代碼。 –