鍦?ActionForm 涓畾涔変竴涓暟緇?String[] selectedOptions 鐢ㄤ簬瀛樻斁澶嶉夋琚変腑鐨勫鹼紝
鏁扮粍 LabelValueBean[] possibleOptions 鐢ㄤ簬鏄劇ず鎵鏈夌殑澶嶉夋鐨勫箋?
import org.apache.struts.action.ActionForm;
import org.apache.struts.util.LabelValueBean;


public class MyActionForm extends ActionForm
{
private LabelValueBean[] possibleOptions;

private String[] selectedOptions;


public MyActionForm()
{

// 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 LabelValueBean[] getPossibleOptions()
{
return possibleOptions;
}


public String[] getSelectedOptions()
{
return selectedOptions;
}


public void setSelectedOptions(String[] selectedOptions)
{
this.selectedOptions = selectedOptions;
}
}
JSP 涓嬌鐢ㄤ互涓嬩唬鐮侊細(xì)
<logic:iterate name="myActionForm" id="item" property="possibleOptions">
<html:multibox property="selectedOptions">
<bean:write name="item" property="value" />
</html:multibox>
<bean:write name="item" property="label" /><br />
</logic:iterate>

]]>