一般都是自己写循环把数据通过checkbox或radio显示出来。struts或hibernate有没有简单的办法,直接把List里面的数据显示出来?而不用自己写循环了。如果没有默认值,就全没有选中,否则,就让默认值相同的checked。一般是自己写,还是有现成的???

解决方案 »

  1.   

    FreeMarker 一个模板语言非常好用的 比JSP简单易用
    如从Action保存一个List在REQUEST里面,在freeer页面里只需要用
    <#list datas as data>
    ${data}
    </#list>
    就可以轻松迭代
      

  2.   

    Struts肯定是可以的,形式大概是这样的(仅供参考):
    <html:select property="level">
      <html:options collection="levelList"/>
    </html:select>
      

  3.   

    查到了是这样的
    <html:select value="3" property="selectedItems">
     <html:options collection="list" property="value" labelProperty="label"/>
    </html:select>value="3"是默认值
    collection="list"是你的列表数据
    property="value" labelProperty="label"是列表的值和标签
      

  4.   

    <html:select   value="3"   property="selectedItems"> 
      <html:options   collection="list"   property="value"   labelProperty="label"/> 
    </html:select> 是checkbox、radio吗?
      

  5.   

    <logic:iterate id="yourBean" name="yourList">
    <bean:write name="yourBean" property="yourProperty" />
    ....这个标签会把yourlist里所有的yourBean里的yourProperty循环显示出来
    <logic:iterate>
    找本struts基础看看