length 属性指定需要遍历的元素的数目, 如果没有设置length 属性, 就遍历集合中的所有元素.
offset 属性指定开始遍历的起始位置, 默认值为 "0" , 表示从集合的第一个元素开始遍历.
indexId 属性定义一个代表当前遍历元素序号的变量, 这个变量被存放在 page 范围内, 可以被标签主体的<bean:write> 标签访问. 例如:
request.setAttribute("Animals", AnimalsList);
<logic:iterate
id="element" // 指定输出元素的名 与 <bean:write> 中name 属性一致
indexId="index" // 遍历元素序号的变量, 这个变量放在page 范围内
name="Animals" // request 中的集合名, 从中取循环取出元素
offset="1" // 从集合的第 2 条记录开始取数
length="2"> // 取出 2 个元素
<bean:write name="index"/>// 输出每个元素的序号, 与indexId 的属性一致
<bean:write name="element"/><br> // 输出每个元素的内容, 与id 的属性一致
</logic:iterate>
若AnimalsList为null,会返回cann't find Animals in any scope的错误.可配合<logic:notEmpty/>使用,将<logic:notEmpty></logic:notEmpty>加在<logic:iterate>外围.
分享到:
相关推荐
jsp脚本和<logic:iterate>标签:实现循环和分支逻辑 jsp脚本和<logic:iterate>标签:实现循环和分支逻辑 jsp脚本和<logic:iterate>标签:实现循环和分支逻辑
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>...
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></...
logic:iterate 产生问题的图
Iterate主要用来处理在页面上输出集合类,集合一般来说是下列之一: 1、 java对象的数组 2、 ArrayList、Vector、HashMap等
Struts Logic标签Struts Logic标签Struts Logic标签Struts Logic标签Struts Logic标签
<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 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:...
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.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、<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.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、<...
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>...
<logic:equal value="modify" property="action" name="projectForm"> <bean:message key="project.project_modify"/> </logic:equal> 上面的示例表示,如果projectForm的action属性等于modify,则处理<bean:message...
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
21. <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop> 22. <prop key="hibernate.cglib.use_reflection_optimizer">true</prop> 23. </props> 24. </property> 25. </bean>...
struts-logic iterate标签学习指南 这标签还不错