在action里request.setAttribute("persons", alls);其中alls是一个list对象 从数据库取值
<logic:iterate id="per" name="persons" scope="request" >
</logic:iterate>
当这么写迭代的时候 可以输出 比如(${per.id})问题是:
现在我想把迭代的内容用下拉框显示 还是per.id 那该怎么写呢?
<logic:iterate id="per" name="persons" scope="request" >
   
    <html:select property="persons">
           <html:option value="${per.name}"></html:option>
      </html:select>
 </logic:iterate>
这么写肯定不对了 请教高手

解决方案 »

  1.   

    <html:select property="persons">
    <logic:iterate id="per" name="persons" scope="request" > 
        <html:option value="${per.id}">${per.name}</html:option>   
    </logic:iterate>
    </html:select> 
    不清楚你要的效果,改了一下
      

  2.   

    <html:select property="persons">
    还是不对..<html:select property="persons">这句话报错
    我就是在formbean里定义了一个String persons
    但是我真的觉得这个没有什么用...我是直接action传值给下拉框 关bean什么事啊?但是下拉框的属性又必须写...
      

  3.   

    javax.servlet.ServletException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
    错误这么提示 不知道啥意思
      

  4.   

    <html:select property="personId">
    <html:option value="">--请选择--</html:option>
    <logic:notEmpty name="persons">
    <html:optionsCollection name="persons" value="id" label="name" />
    </logic:notEmpty>
    </html:select>