如何用struts标签遍历List集合?急! jsf有个像.NET的datagrid一样的标签,struts的迭代标签可以做这个<logic:iterate /> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <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> <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> <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 <logic:iterate>标签中的id="player",没有name属性.不知道为什么这样用会报错,我第一次用,请大家帮忙看看.谢谢! 会出错!判断name属性是否存在。 jsp的代码怎么没有asp的前台代码好懂 但是我name属性加上了,也报同样的错误,我把<logic:present>标签中的name属性去掉了,不知道这样是不是合理.因为我想遍历的list是我用方法直接取到的,方法的返回值是List型的,所以没有响应的Bean类.所以这里就不知道怎么做了! <% 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的! 我List集合存的是一些对象,按你的方法做了,还是报我昨天同样的错误. <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> <% 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的! eclipse怎么写网页程序 spring 请进 web service问题 apache2.2+tomcat6.0.33+JK集群调用WebService的问题 struts2 cos上传问题。在线等。 帮我看看下面代码 特别是数据库连接 关于Struts的logic:iterate中的request问题 Tomcat 5.5.6 安装问题 用Ant编译400多个文件,出现内存溢出异常(JDK1.4.2) 进度显示与中止长事务的问题 structs 中怎么实现多文件上传?? 在线等...xsl中文乱码问题
<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>
<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>
<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
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的!
<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>
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的!