0
我有一個類MyClass
如下提交對象,並列出了Struts1
public class MyClass {
private int fieldOne; //with getter, setter
private String fieldTwo; //with getter, setter
}
我已經按照我的form bean兩場
private MyClass myObject; //with getter, setter
private ArraList<MyClass>myList; //with getter, setter
使用struts1的我要提交的對象和對象的名單由網頁形式。
在struts2中,我們可以像下面那樣獲取對象和列表(注意字段不在操作類而不是表單bean中)。當提交下面的字段時,struts2使用提交的值爲我啓動myObject
和myList
。 (參數Interceptor是在Struts2幕後的魔法師。)
<!-- Object -->
<input type="text" name="myObject.fieldOne" value="1" />
<input type="text" name="myObject.fieldTwo" value="Two" />
...
<!-- List -->
<input type="text" name="myList[0].fieldOne" value="1" />
<input type="text" name="myList[0].fieldTwo" value="Two" />
<input type="text" name="myList[1].fieldOne" value="10" />
<input type="text" name="myList[1].fieldTwo" value="Twenty" />
有沒有辦法在struts1中進行這樣的魔力?