checkBox.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>
<html:submit/><html:cancel/>
</html:form>
FormBean:
private ArrayList<Country> possibleOptions;
private String[] selectedOptions;
public CheckBoxForm()
{
possibleOptions=Dbutil.getBindTable();
}
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;
}
Action:选中状态和打勾
String[] str={"2","3"};
CheckBoxForm f=(CheckBoxForm)form;
f.setSelectedOptions(str);
return new ActionForward("/checkBox.jsp");