In the Struts framework, you often encounter multi-line forms. How to effectively use the automatic collection mechanism provided by the Struts framework to handle it? It provides a simple method. You can use list to solve this problem. Every element in List It is an effective object. For example: Class ... testbean ... {private list = new arraylist (); ...... ... ......}} where Test List Each element is another subTestBeanclass ... SubtestBean {private int id; private string name; get ... () {} set ... (...) {}} This time we are defining multiple rows It can be handled (assuming TestBean is already in Request):
/ * * (Non-javadoc) * * @see java.util.list # get (int) * / public object get (int index) {while (index> = size ()) {add (new subTestBean ()); } Return super.get (index);}}
Then we put the private list test = new arraylist () in TestBean; replaced with private list test = new testArrayList (); which can be automatically collected.