- Struts中 <html:radio> <html:multibox> <html:select> 使用
- jsp:
- <html:form action="/checkBox">
- <logic:iterate id="item" name="checkBoxForm" property="possibleOptions">
- <html:multibox property="selectedOptions">
- <bean:write name="item" property="ID"/>
- </html:multibox>
- <bean:write name="item" property="countryID"/>
- </logic:iterate>
- <br>
- <logic:iterate id="item2" name="checkBoxForm" property="possibleOptions">
- <html:radio property="radioSelected" value="${item2.ID}"></html:radio>
- <bean:write name="item2" property="countryID"/>
- </logic:iterate>
- <html:select property="dropDownSelected">
- <html:optionsCollection property="possibleOptions" label="countryID" value="ID"/>
- </html:select>
- <html:submit/><html:cancel/>
- </html:form>
- CheckBoxForm:
- public class CheckBoxForm extends ActionForm {
- private ArrayList<Country> possibleOptions;
- private String[] selectedOptions;
- private String radioSelected;
- private String dropDownSelected;
- public String getRadioSelected() {
- return radioSelected;
- }
- public void setRadioSelected(String radioSelected) {
- this.radioSelected = radioSelected;
- }
- public CheckBoxForm()
- {
- possibleOptions=Dbutil.getBindTable();
- // Initialise the LabelValueBeans in the possibleOptions array.
- // LabelValueBean[] lvBeans = new LabelValueBean[4];
- //
- // lvBeans[0] = new LabelValueBean("Alpha", "A");
- // lvBeans[1] = new LabelValueBean("Beta", "B");
- // lvBeans[2] = new LabelValueBean("Charlie", "C");
- // lvBeans[3] = new LabelValueBean("Delta", "D");
- // this.possibleOptions = lvBeans;
- }
- public ArrayList<Country> getPossibleOptions() {
- return possibleOptions;
- }
- public void setPossibleOptions(ArrayList<Country> possibleOptions) {
- this.possibleOptions = possibleOptions;
- }
- public String[] getSelectedOptions()
- {
- return selectedOptions;
- }
- public void setSelectedOptions(String[] selectedOptions)
- {
- this.selectedOptions = selectedOptions;
- }
- public String getDropDownSelected() {
- return dropDownSelected;
- }
- public void setDropDownSelected(String dropDownSelected) {
- this.dropDownSelected = dropDownSelected;
- }
- }
- Struts_config:
- <form-beans >
- <form-bean name="checkBoxForm" type="wang.CheckBoxForm" />
- </form-beans>
- <action
- attribute="loginForm"
- input="/login.jsp"
- name="loginForm"
- path="/login"
- scope="request"
- type="wang.LoginAction">
- <forward name="seccess" path="/seccess.jsp" />
- <forward name="fail" path="/fail.jsp" />
- <forward name="aaa" path="/checkBox.jsp" />
- </action>
Struts中 html:radio,html:multibox,html:select 使用实例
最新推荐文章于 2016-07-17 13:52:00 发布