我在action中有一个集合然后我的action要转向到jsp页面中而jsp页面中有一个下拉框下拉框的内容是action中的集合的值不知道这样该怎么写?我不希望我的页面中出现脚本代码<%  %>希望能用EL表达式或者是在这个jsp页面对应的actionForm中去获取传过来的值

解决方案 »

  1.   

    用标签
    和table 
    <td>
    <html:select name="xxxform" property="">
    <logic:iterate id="item" name="xxxForm" property="xxxlist" scope="request">
    <bean:write name="item" property="">
      

  2.   

    1,在action中将值存到request中
    request.setAttribute("rootlist",集合值);
    2,jsp页面运用struts标签
     <html:select name="MSysParameterForm" property="filepath" >
        <html:options collection="rootlist(request名)" property="optionvalue(集合值里面存的值名称)" labelProperty="optionlabel"/>
        </html:select>
      

  3.   

    我在action中的集合是用Vector哪么在html页面中的property和labelProperty应该对应什么呢?
      

  4.   

    先将你的集合 在action 中放到 request 中 。request.setAttribute("list",arrayList);在页面上<select >
    <c:forEatch items="${list}"  val="obj">
            <option value="${obj.属性名}"> ${obj.属性名} </option>
    </c:forEatch >
    </select>你也可以用struts 的iterator 标签。
      

  5.   


    我在action中的集合是用Vector 哪么在html页面中的property和labelProperty应该对应什么呢?
      

  6.   


    Request.setAttribute("fields",fields);
    <html:select property="fieldType">
        <html:options collection="fields" property="value"/>
    </html:select>
      

  7.   


    property="value"/这个代表什么
      

  8.   


    如果楼主想用vector的话
    那首先将vector值存到request中
    request.setAttribute('selOpt',Vector);然后在jsp<select name="sel">
    <logic:iterate id="随便一个别名(selopt)" name="selOpt(对应request)" indexId="ind"><option value=""><bean:write name="selopt(对应上面id)"></option></logic:iterate></select>
      

  9.   

    <c:forEach var="list" varStatus="status" items="${replyDetail}">
      <tr>
    ${list.getUser}
      </tr>
    </c:forEach>用<c:forEach> 用起真方便.
      

  10.   

    <select name="sel">
    <logic:iterate id="随便一个别名(selopt)" name="selOpt(对应request)" indexId="ind"><option value=""><bean:write name="selopt(对应上面id)"></option></logic:iterate></select>