ActionForm 里:
jsp里:
< html:select property="userid">
< html:options collection="userHtmlSelect" property="value" labelProperty="label"/>
< /html:select>
java 代码
- private java.lang.String userid="admin"; //默认值
- Action里:
- form.setUsrid("guest");//修改默认值
- //设置下拉选项
- List rs = new java.util.ArrayList();
- rs.add(new org.apache.struts.util.LabelValueBean("管理员",
- "admin"));
- rs.add(new org.apache.struts.util.LabelValueBean("客人","guest"));
- request.getSession().setAttribute("userHtmlSelect",rs);
- return mapping.findForward("index");
< html:select property="userid">
< html:options collection="userHtmlSelect" property="value" labelProperty="label"/>
< /html:select>