[請教] 如何使用nested標籤組裝及顯示一對多的BEAN屬性

mm_hotsky發表於2005-04-11





問題描述:

  JSP頁面的FORM表單對應ActionForm中的一個BEAN屬性,而BEAN屬性下面有一個物件陣列對應頁面中的某個欄目的多行資料,並且可以動態新增行。
  經過試驗,不知道為什麼動態行中的資料總是提交不到ActionForm中,是不是我的程式碼有問題?!


以下是我的部分程式碼:


jsp:

<html>
<html:form action="...">
...
<nested:nest property="note">
...
<nested:iterate property="receps">
<nested:text property="num" indexed="true">
<nested:text property="sign" indexed="true">
</nested:iterate>
...
</nested:nest>
...
 </html:form>
</html>



ActionForm:

public class OutForm extends ActionForm {
private Note note = new Note();
}


Note:

public class Note {
// 初始化陣列是為了顯示頁面的時候有一個空白行
private Recep[] receps = new Recep[]{new Recep()};
}


Recep:

public calss Recep {
// 用來接收使用者輸入的值
private String num = null;
private String sign = null;
}

相關文章