Get data LIST from the database, put the data into the Request
Use SetAttribute ("AliST", AlIST)
Two attributes in A (String ID, String Value)
1. Use JSTL's Foreach method
option>
c: by>
The first use directly writes all options in the middle. 0-15 html: option> 15-20 html: option> 30 OR Above html: option> The second: put the option in a collection (here you use list). In the actual project, more is possible data from DB, file, and the like. This situation is used. Procedure to put the option in the list in Action processing // prepare the age selector list.list Agelist = New ArrayList (); Agelist.add (New Labelvaluebean); Agelist.Add (New LabelValuebean); Agelist.Add (New LabelValuebean) 20-30 "," 20-30 ")); Agelist.add (New Labelvaluebean (" 30 or Above "," 30 or Above ")); Request.SetAttribute (" alist ", alist); use LabelValueBean here, Optional, inexpressionism = "alist" labelproperty = "value" property = "id" /> As long as the Bean filled in Alist has Value and ID attributes Third type, put this list as an attribute of Form. Add Alist's setter and getter. Form as follows in Form. // the list can be a form. F.setagelist (alist); 1. Get data from the database, you should put the data in the request in the action 2. After the data is taken out, put it in a list or collection or map, I am used to using List 3. Take data from List or other containers should use or 4. and The outer layer must be , so you must define in the Formbean 5. Since you have to use these tags, you must define FORMBEAN 6. Take data from Action, take List as an example List list = xxxxx; // Get data from the drop-down list from the database Request.setttribute ("List", List); Display on the page ... html: select> ... html: form> Add a little bit: Because data is deserved from the database, it is generally called DAO in the action, which is transmitted to the page; when it is generally tag In addition, if the data is not deteted from the database, but the code is fixed, this is generally put into the actionform, and the attribute is taken on the page, and it is generally
The first use directly writes all options in the middle.
0-15 html: option> 15-20 html: option> 30 OR Above html: option>
The second: put the option in a collection (here you use list). In the actual project, more is possible data from DB, file, and the like. This situation is used.
Procedure to put the option in the list in Action processing // prepare the age selector list.list Agelist = New ArrayList (); Agelist.add (New Labelvaluebean); Agelist.Add (New LabelValuebean); Agelist.Add (New LabelValuebean) 20-30 "," 20-30 ")); Agelist.add (New Labelvaluebean (" 30 or Above "," 30 or Above ")); Request.SetAttribute (" alist ", alist); use LabelValueBean here, Optional, inexpressionism = "alist" labelproperty = "value" property = "id" />
As long as the Bean filled in Alist has Value and ID attributes
Third type, put this list as an attribute of Form.
Add Alist's setter and getter. Form as follows in Form.
// the list can be a form.
F.setagelist (alist);
1. Get data from the database, you should put the data in the request in the action
2. After the data is taken out, put it in a list or collection or map, I am used to using List
3. Take data from List or other containers should use or
4. and The outer layer must be , so you must define in the Formbean
5. Since you have to use these tags, you must define FORMBEAN
6. Take data from Action, take List as an example
List list = xxxxx; // Get data from the drop-down list from the database
Request.setttribute ("List", List);
Display on the page
... html: select> ... html: form>
Add a little bit:
Because data is deserved from the database, it is generally called DAO in the action, which is transmitted to the page; when it is generally tag
In addition, if the data is not deteted from the database, but the code is fixed, this is generally put into the actionform, and the attribute is taken on the page, and it is generally