同样生成一个Table
<table id="checkTable" align="center" cellpadding="5" cellspacing="0" border="0" width="100%">
<tbody>
<logic:iterate id="item" name="list" type="com.worthtech.app.bean.User" indexId="
index">
<%
//int index=((java.lang.Integer)pageContext.findAttribute("index")).intValue();//自增的索引,相当于for里面的i,logic:iterate里用起来比较麻烦,红色部分必须一致
if((
index%2)==0){//斑马线
%>
<tr class="SelcetOff">
<%}else{%>
<tr class="SelcetOn">
<%}%>
<td><div align="center"><bean:write name="item" property="userName"/></div></td>
<td><div align="center"><bean:write name="item" property="address"/></div></td>
</tr>
</logic:iterate>
</tbody>
</table>
<table id="checkTable" align="center" cellpadding="5" cellspacing="0" border="0" width="100%">
<tbody>
<%
if (request.getAttribute("list") != null) {
java.util.List l = (java.util.List) request.getAttribute("list");
for (int i = 0; i < l.size(); i++) {
com.worthtech.app.bean.User user = (com.worthtech.app.bean.User) l.get(i);
if(i%2==0){//斑马线
out.print("<tr class='SelcetOff'>");
}else{
out.print("<tr class='SelcetOn'>");
}
out.print("<td><div align='center'>"+ user.getUserName() + "</div></td>");
out.print("<td><div align='center'>"+ user.getAddress() + "</div></td>");
out.print("</tr>");
}
}
%>
</tbody>
</table>
用for循环比较自由度大,方便。比如要对user.getAddress()进行操作,可以out.print("<td><div align='center'>"+
Util.parse(user.getAddress()) + "</div></td>");
如果使用<logic:iterate>里的<bean:write name="item" property="
address"/>就必须这样:
<bean:define id="var" name="item" property="
address" type="java.lang.String"/>
<% java.lang.String address=var;%>
<td><div align="center"><%=Util.parse(address) %></div></td>
这样显得很麻烦。
总结:使用<logic:iterate>灵活度不高
分享到:
相关推荐
jsp脚本和<logic:iterate>标签:实现循环和分支逻辑 jsp脚本和<logic:iterate>标签:实现循环和分支逻辑 jsp脚本和<logic:iterate>标签:实现循环和分支逻辑
1. Map里存放的是bean时<br><br><logic:iterate id="destMap" name="srcMap"><br><br> <bean:define id="bean" name="destMap" property="value" /><br><br> <bean:write name="bean" property="name" /><br><br></...
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br><html><br> <head><br> </head><br> <body><br> <table><br> <tr><br> <td><%@ include file="../menu.txt"%><br> </td><br> </tr>...
<logic:iterate id="tr" name="grid" indexId="index2"> <html:link action="/jsp/office/exchange/preModifyExchangeDoc" paramId="exchangeDocOID" paramName="tr" paramProperty="key"> <tr bgcolor="#ffffff...
logic:iterate 产生问题的图
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>标签 16.4.6、<html:hidden...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>标签 16.4.6、<html:hidden...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<html:textarea>...
16.3.5、重定向标签:<logic:redirect> 16.4、Html标签 16.4.1、<html:form>标签 16.4.2、<html:text>与<html:password>标签 16.4.3、<html:radio>标签 16.4.5、<...
Iterate主要用来处理在页面上输出集合类,集合一般来说是下列之一: 1、 java对象的数组 2、 ArrayList、Vector、HashMap等
<logic:iterate id="temp" name ="list"> <tr align="center"> <td><bean:write name="temp" property="userName"/></td> <td><bean:write name="temp" property="pwd"/></td> <td><bean:...
Struts Logic标签Struts Logic标签Struts Logic标签Struts Logic标签Struts Logic标签
NULL 博文链接:https://duqiangcise.iteye.com/blog/286764
struts-logic iterate标签学习指南 这标签还不错
struts标签库 文章目录 bean:cookie 2 bean:define 3 bean:header 4 ...logic:iterate 21 logic:present 23 logic:messagesPresent 23 logic:empty 24 logic:match 24 logic:equal 25 logic:forward 26 总结 26
<logic:equal value="modify" property="action" name="projectForm"> <bean:message key="project.project_modify"/> </logic:equal> 上面的示例表示,如果projectForm的action属性等于modify,则处理<bean:message...