我用的form是DynaActionForm 从DB拿到的一个LIST 中有一个字段是我前台要用的,要放在一个SELECT里边, 中间想放到request里边,然后通过<html:select>这个标签拿到该字段的集合,但是不知道怎么写,各位大虾帮帮忙,具体应该怎么放,给小弟个例子,谢谢

解决方案 »

  1.   

    <html:select property="" name="">
    <html:optionsCollection label="" name=""></html:optionsCollection>
    </html:select>
      

  2.   

    <% java.util.List list = new java.util.ArrayList();
     list.add(new  org.apache.struts.util.LabelValueBean("管理员",
                        "admin"));
              list.add(new  org.apache.struts.util.LabelValueBean("客人","guest"));
    request.setAttribute("list",list);
     %>
    <html:form action="/admin" scope="request">
    id : <html:select property="id">
      <html:options collection="list" property="value" labelProperty="label"/> </html:select>

    <html:submit/><html:cancel/>
    </html:form>
      

  3.   

    那的list 可以放到action中赋值,
      

  4.   

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