Multi-line forms in the Struts framework

xiaoxiao2021-03-06  44

Multi-line forms in the Struts framework

Select BLOG in XTime1980 often encounter multi-line forms in the Struts framework, how to effectively use the auto collection mechanism provided by the Struts framework? A simple method can be provided. You can solve this problem with List. Each element in the middle is an effective object. For example: Class ... TestBean ... {private list test = new arraylist (); ...... ......]}} Each element in the Test List is another subTestBeanClass ... subTestBean {private int id; private string name; get ... () {} set ... (...) {}} so we are defined When you are, you can do this (assuming TestBean is already placed in Request): This will be automatically displayed, but it is not able to collect automatically, how can I reclaim correctly? Require it to do a little hand on Test List, Inheriting an arraylist, covering its GET (i) method, for example: Class TestarrayList Extends ArrayList {/ * * (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 array in TestBean List (); replacement to private list test = new testArrayList (); this can be automatically collected.

转载请注明原文地址:https://www.9cbs.com/read-79686.html

New Post(0)