呵呵,有点看不懂你的意思,什么是“collection所在的bean”????
不过可以贴一下jsp中使用的代码,并简单说明一下。
<html:select property="station">
   <html:optionsCollection name="stationList" value="value" label="label" />
</html:select>
说明一下,至于<html:select/>中的property就不多解释了,对应的是ActionForm Bean中的某个station属性。
在<html:optionsCollection/>中的name属性对应的是一个Collection类集对象,该对象中的元素是bean,该bean有两个属性,分别是label和value。希望这些说明能对楼主有帮助。

解决方案 »

  1.   

    谢谢雅风,其实这几个属性代表的意思我都知道,不过,我想知道的是ActionForm Bean文件里面的那个集合是怎么写的。我自己写了,老是说那个集合没有getter,明明在里面已经写了,假设那个collection 类对象叫typeList,那么这个typeList在ActionForm Bean里面怎样定义,怎样写setter和getter?
      

  2.   

    <html:select property="category">
    <html:optionsCollection name"cat" property="options"/>
    </html:select>
    同时使用NAME和PROPERTY,属性指定对象的名称和字段,将调用该对象的值获取方法以返回一个用来生成选项的集合
      

  3.   

    ike_Adriano: 如果 cat.java是在包“product”下的,那么name该怎么写?我试过name="product.cat",但说“can not find bean cat in any scope”
      

  4.   

    假设那个collection 类对象叫typeList,那么这个typeList在ActionForm Bean里面怎样定义,怎样写setter和getter?==========================
    这样不知道行不行,collection类对象我一般是通过在Action中用request.setAttribute("typeList",list)的方式来传递给页面,然后在页面中使用 <logic:iterate/>来迭代.
    或者最简单的方法就是继承TagSupport类,自己写个和struts中的html或者logic等tag一样的tag,然后在页面中调用,这个方法个人感觉更好.
      

  5.   

    <html:optionsCollection name="stationList" value="value" label="label" />
    我也来补充一下,这里name代表一个存储在某个作用域中的bean,即page,request,session,或者application存放的的变量名
    如是在进这页面前有一个request.setAttribe("stationList",list);
    list的可以是任何收集类!
    list可以是对象
    如user对象,有一个userId,userName,有相应的getter方法
    则可以这样写
    <html:optionsCollection name="stationList" value="userId" label="userName" />
    这里,就把userId作为值,userName作为显示text在select里了
      

  6.   

    如果我想把 这个collection类,放到Constants.java里面(就是全局的常量),作为静态变量生成,那么,怎样使这个collection在web project一装载时就生成?因为用户一点击入这个JSP文件,就要在<html:optionsCollection中填充了。
      

  7.   

    <html:hidden name="PersonAuthForm" property="formAction" /><html:text name="PRITeamForm" property="teamData.teamName" maxlength="100" size="50"/>
    <html:textarea name="PRITeamForm" property="teamData.teamDesc" cols="50" rows="6"/>
    <html:hidden name="PRITeamForm" property="teamData.orgID" /><logic:notEmpty name="PRITeamForm" property="teamList">collections 1 info is object 
    <logic:iterate indexId="index" id="info" name="PRITeamForm" property="teamList">
    <logic:iterate indexId="index" id="info" name="PersonAuthForm" property="userAuthList"  type="com.queryPersonAuth.bo.UserAuthData"><bean:write name="info" property="userInfo.userName" />-->info.userInfo.userName<bean:write name="index" />num
    select collection 1 optionsCollection
    使用LabelValueBean作下拉框
    <html:select name="PersonAuthForm" property="orgId" onchange="changeOrg()">
    <html:option value="-1">-不选择-</html:option>
    <html:optionsCollection name="PersonAuthForm" property="orgList"/>
    //display select and the object is labelobject key--value -->LabelValueBean  
    </html:select>
    使用自定义bean 作下拉框
    <bean:define id ="sec" name="workloadForm" property="secList" scope="request"/>
    <html:select name="workloadForm" property="queryConditionData.sectionId" > 
    <html:options collection ="sec" property="id" labelProperty="label"/> ----id属性值为 value label属性值为 label
    </html:select>    <bean:define id="teamList" name="TeamForm" property="teamList"  type="java.util.Vector" />
    if(teamList!=null&&teamList.size()>0)
    <a name="position"></a>
     <script>
    location.href="#position";
    </script>定义对象
    <bean:define id="WorkConsignData" name="WorkConsignForm" property="workConsignData" type="com.workconsign.bo.WorkConsignData"/>定义变量
     <bean:define id="cssstyle"><%= index.intValue() % 2 %></bean:define>使用
    <logic:equal name="cssstyle" value="0"> class="even"</logic:equal><logic:notEmpty name="PRIGroupUserForm" property="userList">   <logic:present  name="insertRole">
               <font color=red> 不允许添加同样的角色</font>
      </logic:present>