jsf有个像.NET的datagrid一样的标签,struts的迭代标签可以做这个<logic:iterate />

解决方案 »

  1.   

    <logic:present name="xxxForm" property="list">
        <logic:iterate id="qual" name="xxxForm" indexId="index" property="list" type="cn.com.xx.XBean" scope="request">
             <input type="text" name="xxDate" id="acqDate<bean:write name="index"/>" value="<bean:write name="xx" property="xxDate" />" readonly="true" />
        </logic:iterate>
    </logic:present>在struts-config.xml中<form-beans>
    <form-bean name="xxxForm" type="cn.com.xx.XForm"></form-bean>
    </form-beans>
      

  2.   

    <logic:present name="preserveEffeciencyActionForm" property="preserveEffeciencyList">
             <logic:iterate id="element" name="preserveEffeciencyActionForm" property="preserveEffeciencyList" indexId="ind">
              <tr align="center">
                      <td align="left" class="headTable" width="2%" ><%=ind+1 %></td>
                      <td align="left" class="headTableRwBg" width="8%" ><input  type="text" class="txtField" size="1" readonly  value="<bean:write name="element" property="locationCode"/>"></td>
                      <td align="left" class="headTableRwBg" width="20%" ><input  type="text" class="txtField" size="1" readonly  value="<bean:write name="element" property="locationUseType"/>"></td>
                      <td align="left" class="headTableRwBg" width="15%" ><input  type="text" class="txtField" size="1" readonly  value="<bean:write name="element" property="locationDipathType"/>"></td>
                      <td align="left" class="headTableRwBg" width="15%" ><input  type="text" class="txtField" size="1" readonly  value="<bean:write name="element" property="maxCapacity"/>"></td>
                      <td align="left" class="headTableRwBg" width="15%" ><input  type="text" class="txtField" size="1" readonly  value="<bean:write name="element" property="maxCapacityRate"/>"></td>
                      <td align="left" class="headTableRwBg" width="10%" ><input  type="text" class="txtField" size="1" readonly  value="<bean:write name="element" property="nowCapacity"/>"></td>
                      <td align="left" class="headTableRwBg" width="5%" ><input  type="text" class="txtField" size="1" readonly  value="<bean:write name="element" property="nowCapacityRate"/>"></td>
                      <td align="left" class="headTableRwBg" width="5%" ><input  type="text" class="txtField" size="1" readonly  value="<bean:write name="element" property="sumCapacity"/>"></td>
                      <td align="left" class="headTableRwBg" width="5%" ><input  type="text" class="txtField" size="1" readonly  value="<bean:write name="element" property="sumCapacityRate"/>"></td>
                      </tr>
             </logic:iterate>
             </logic:present>
      

  3.   

    <logic:present name="players">
    <logic:iterate name="player" type="model.PlayerBasicInfo" id="" scope="request">
    <form action="">
    <tr align="center">
      <input type="hidden" name="id" value="<bean:write name="player" property="id">">
      <td><bean:write name="player" property="playerAccount"/></td>
      <td><bean:write name="player" property="roleName"/></td>
      <td><bean:write name="player" property="playerName"/></td>
      <td><bean:write name="player" property="connectionWay"/></td>
      <td><bean:write name="player" property="commitClerk"/></td>
    </tr>
    </form>
    </logic:iterate>
    </logic:present>
    我是这样用的,但是在编译的时候就报错了,错误是:"showPlayer.jsp": org.apache.jasper.JasperException: file:D:/serviceGS/WebModule/STGS/service/showPlayer.jsp(32,40) According to TLD, tag bean:write must be empty, but is not
      

  4.   

    <logic:iterate>标签中的id="player",没有name属性.不知道为什么这样用会报错,我第一次用,请大家帮忙看看.谢谢!
      

  5.   

    会出错!判断name属性是否存在。
      

  6.   

    jsp的代码怎么没有asp的前台代码好懂
      

  7.   

    但是我name属性加上了,也报同样的错误,我把<logic:present>标签中的name属性去掉了,不知道这样是不是合理.因为我想遍历的list是我用方法直接取到的,方法的返回值是List型的,所以没有响应的Bean类.所以这里就不知道怎么做了!
      

  8.   

    <%
     List list=new ArrayList(); 
    //在Action 中,或jsp页面设置一个 list ,并放入 request 、page、或 session、Apliction等范围
     list.add("a");
     list.add("b");
     list.add("c");
     list.add("d");
    request.setAttribute("request_list", list);
    %>
     <logic:present name="request_list"> //如果 变量在四种范围内存在那么执行
    <logic:iterate name="request_list"  id="new_name" scope="request"> 
    <bean:write name="new_name />  
    </ogic:iterate>
    </logic:present> 非常简单的例子,估计好多人没有这么用过 Struts 的标签不光光是操作JavaBean的!
      

  9.   

    我List集合存的是一些对象,按你的方法做了,还是报我昨天同样的错误.
      

  10.   

    <logic:iterate id="list" name="list">
    <tr >

    <td><bean:write name="list" property="billTypeName"/></td>
    <td><bean:write name="list" property="makeMan"/></td>
    <td><bean:write name="list" property="makeDate"/></td>
    <td><bean:write name="list" property="subFuncName"/></td>
    <td><bean:write name="list" property="conditionName"/></td>
    </tr>
    </logic:iterate>
      

  11.   

    <%
     List list=new ArrayList(); 
    //在Action 中,或jsp页面设置一个 list ,并放入 request 、page、或 session、Apliction等范围
     list.add("a");
     list.add("b");
     list.add("c");
     list.add("d");
    request.setAttribute("request_list", list);
    %>
     <logic:present name="request_list"> //如果 变量在四种范围内存在那么执行
    <logic:iterate name="request_list"  id="new_name" scope="request"> 
    <bean:write name="new_name"  property="对象属性名"/>  
    </ogic:iterate>
    </logic:present> 非常简单的例子,估计好多人没有这么用过 Struts 的标签不光光是操作JavaBean的!