- 浏览: 865765 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
hzw2312:
C = sin(MLatA)*sin(MLatB)*cos(M ...
根据地球上任意两点的经纬度计算两点间的距离 -
zhang_sun:
rewind方法的limit又是多少呢?等于capacity? ...
ByteBuffer的flip,clear及rewind区别 -
kalogen:
一种每次都获取到不同的随机数的办法int ranseed=12 ...
J2ME中Random类的使用 -
kalogen:
估计部署在某个端口下吧,仔细检查一下发布的配置文件
Tomcat负载均衡和集群环境的搭建 -
zhuchao_ko:
文件大点就嗝屁了~~~
Axis 1.4 上传二进制文件(base64Binary)
English Title:(Turn) of label of the Iterator in Struts2 relevant use 在说明s:iterator标签的使用前,先了解下struts2中的Value Stack。这里参考了webwork中对Value Stack的描述,由于struts2是在webwork的基础上进行升级的,因此webwork对于Value Stack的表述同样适用于struts2。在这里不描述Value Stack具体做什么,但有两点需要注意: 一个value stack本质上是一个List; [0] --- 返回 [model,action,others]; 1) 、访问 days defined List<String> days ["Monday","Thursday","Friday","Sunday"] view plaincopy to clipboardprint? 2) 、使用 top 关键字使用(过滤掉Monday) defined List<String> days ["Monday","Thursday","Friday","Sunday"] view plaincopy to clipboardprint? top 指代当前迭代元素,可以为对象; 3)、使用 last / first 关键字使用 defined String[][] aTs = { { "一", "二", "三", "四" },{ "一一", "二二", "三三", "四四"} }; view plaincopy to clipboardprint? 下面的例子要实现每行输出颜色不同的效果。 defined List<String> days ["Monday","Thursday","Friday","Sunday"] view plaincopy to clipboardprint? odd关键字用来判断当前迭代位置是否为奇数行。odd返回boolean类型; even : boolean - 如果当前迭代位置是偶数返回true 假定countries是一个List对象,每一个country有一个name属性和一个citys List对象,并且每一个city也有一个name属性 。那么我们想要在迭代cities是访问countries的name属性就的用如下方式: 这里的 <ww:property value="name"/>取的是ctiy.name;<ww:property value="[1].name"/>取得是country.name 本文来自CSDN博客,转载请标明出处: Showing S:iBefore the use of Terator label, understand the Value Stack in next Struts2 first. Consulted be opposite in Webwork here the description of Value Stack, because Struts2 undertakes upgrading on the foundation of Webwork, because of this Webwork to Value Stack state apply to Struts2 likewise. Do not describe Value Stack here specific what to do, but have needed to notice at 2 o'clock: A Value Stack is a List substantially; [0]---Return [Model, action, others] ; Days of 1) , visit Defined List<String> Days ["Monday" , "Thursday" , "Friday" , "Sunday" ] View Plaincopy To Clipboardprint? Key word of 2) , use Top is used (filter Monday) Defined List<String> Days ["Monday" , "Thursday" , "Friday" , "Sunday" ] View Plaincopy To Clipboardprint? Top points to element of acting current iteration, can be an object; Key word of 3) , use Last / First is used Defined One " of String[][] ATs = {{" , "2 " , "3 " , "4 " } , {" one by one " , "22 " , "33 " , "44 "} }; View Plaincopy To Clipboardprint? The Status attribute in Iterator label represents the position of current iteration; The example below should achieve the result with every output different color. Defined List<String> Days ["Monday" , "Thursday" , "Friday" , "Sunday" ] View Plaincopy To Clipboardprint? Odd key word uses judgement whether is current iteration position odd travel. Odd returns Boolean type;Evne key word uses judgement whether does current iteration position go for even number. Even returns Boolean type Even: If Boolean - is current iteration position is even number returns TrueOdd: If Boolean - is current iteration position is odd return TrueCount: The computation that Int - returns current iteration position (from 1 begin)Index: The number that Int - returns current iteration position (from 0 begin)First: If Boolean - is current iteration position is the first when return TrueLast: If Boolean - is current iteration position is last when return TrueModulus(operand: Int) : Int - returns current count (from 1 begin) with the modulus that appoints operand Assume Countries is object of a List, each Country has attribute of a Name and boy or girl friend of a Citys List, and each City also has property of a Name. So we want to be in the Name attribute that iteration Cities is visit Countries with following means: View Plaincopy To Clipboardprint? The <ww:p hereWhat Roperty Value="name"/> takes is Ctiy.name;<ww:pRoperty Value="[1].name"/> is obtained is Country.name The article comes from CSDN rich guest, reprint indicate please provenance:
在栈中调用[n]将返回一个从位置n开始的子栈;
对于2举个例子说明。假定Value Stack包含了[model,action,others],那么
[1] --- 返回 [action,others];
[2] --- 返回 [others];
现在将开始介绍s:iterator的一些使用。以下代码片段均在开发环境eclipse3.4 wtp、tomcat5.5、jdk5上使用struts2.1.6测试通过。
<s:iterator value="days"><s:property /></s:iterator>
<s:iterator value="days"><s:property /></s:iterator>
<s:iterator value="days">
<s:if test="top!='Monday'">
<s:property />
</s:if>
</s:iterator>
<s:iterator value="days">
<s:if test="top!='Monday'">
<s:property />
</s:if>
</s:iterator>
这里的top可用[0].top替代,但不能使用[0]。[0]代表整个栈对象。如果单纯调用[0]将会调用其toString()方法输出对象信息;
<!--遍历二维数组,The trick here is to use 'top' as the value for the inner iterator-->
<s:iterator value="aTs" status="of">
<s:if test="#of.last"><br/></s:if>
<s:iterator value="top">
<!--亦可用[0].top替代。如果单纯用[0],则会同时打印该处栈对象信息-->
<s:property />
</s:iterator>
</s:iterator>
<!--遍历二维数组,The trick here is to use 'top' as the value for the inner iterator-->
<s:iterator value="aTs" status="of">
<s:if test="#of.last"><br/></s:if>
<s:iterator value="top">
<!--亦可用[0].top替代。如果单纯用[0],则会同时打印该处栈对象信息-->
<s:property />
</s:iterator>
</s:iterator>
iterator 标签中的status属性代表当前迭代的位置;
#of.last用于判断当前是否跌到的最后一个元素;
last返回一个boolean类型;
first 返回一个boolean类型;
4)、使用 odd / even 关键字
<!--奇数行显示为红色,偶数行显示为绿色-->
<s:iterator value="days" status="offset">
<s:else>
<s:if test="#offset.odd==true">
<li style="color: red" mce_style="color: red"><s:property /></li>
</s:if>
<s:else>
<li><s:property /></li>
</s:else>
</s:else>
</s:iterator>
<!--奇数行显示为红色,偶数行显示为绿色-->
<s:iterator value="days" status="offset">
<s:else>
<s:if test="#offset.odd==true">
<li style="color: red" mce_style="color: red"><s:property /></li>
</s:if>
<s:else>
<li><s:property /></li>
</s:else>
</s:else>
</s:iterator>
evne关键字用来判断当前迭代位置是否为偶数行。even返回boolean类型
5)、总结下,当声明iterator的status属性时,通过#statusName.method 可以使用以下方法:
odd : boolean - 如果当前迭代位置是奇数返回true
count : int - 返回当前迭代位置的计数(从1开始)
index : int - 返回当前迭代位置的编号(从0开始)
first : boolean - 如果当前迭代位置是第一位时返回true
last : boolean - 如果当前迭代位置是最后一位时返回true
modulus(operand : int) : int - 返回当前计数(从1开始)与指定操作数的模数
6)、最后再来看下在iterator中调用value stack的用法。
view plaincopy to clipboardprint?
<s:iterator value="countries">
<s:iterator value="cities">
<s:property value="name"/>, <s:property value="[1].name"/><br>
</s:iterator>
</s:iterator>
<s:iterator value="countries">
<s:iterator value="cities">
<s:property value="name"/>, <s:property value="[1].name"/><br>
</s:iterator>
</s:iterator>
<ww:property value="[1].name"/> 等价于 <ww:property value="[1].top.name"/>
we refer to a specific position on the stack: '[1]'. The top of the stack, position 0, contains the current city, pushed on by the inner iterator; position 1 contains the current country, pushed there by the outer iterator.(city处于当前栈,即top或者[0],而[1]指明了外层iterator对象,即country)
'[n]'标记引用开始位置为n的子栈(sub-stack),而不仅仅是位置n处的对象。因此'[0]'代表整个栈,而'[1]'是除top对象外所有的栈元素。
==========English==========
Call in inn [N] will return to begin from positional N child inn;
To 2 lift an example specification. Assume Value Stack was included [Model, action, others] , so
[1]---Return [Action, others] ;
[2]---Return [Others];
Will begin to introduce S:i nowOf Terator a few use. Extract of the following code all is developing environmental Eclipse3.4 Wtp, Tomcat5.5, Jdk5 to go up use Struts2.1.6 test is passed.
<s:iTerator Value="days"><s:pRoperty /></s:iTerator>
<s:iTerator Value="days"><s:pRoperty /></s:iTerator>
<s:iTerator Value="days">
<s:iF Test="top! ='Monday'">
<s:pRoperty />
</s:iF>
</s:iTerator>
<s:iTerator Value="days">
<s:iF Test="top! ='Monday'">
<s:pRoperty />
</s:iF>
</s:iTerator>
The Top here is usable [0].top is replaced, but cannot use [0] . [0] represents whole inn target. If pure call [0] will call its ToString() method to export target information;
< ! - - all over all previous 2 dimension group, the Trick Here Is To Use 'top' As The Value For The Inner Iterator- - >
<s:iTerator Value="aTs" Status="of">
<s:iF Test="#of.last"><br/></s:iF>
<s:iTerator Value="top">
< ! - - Yi Ke is used [0].top is replaced. If pure with [0] , can print information of target of the place inn at the same time- - >
<s:pRoperty />
</s:iTerator>
</s:iTerator>
< ! - - all over all previous 2 dimension group, the Trick Here Is To Use 'top' As The Value For The Inner Iterator- - >
<s:iTerator Value="aTs" Status="of">
<s:iF Test="#of.last"><br/></s:iF>
<s:iTerator Value="top">
< ! - - Yi Ke is used [0].top is replaced. If pure with [0] , can print information of target of the place inn at the same time- - >
<s:pRoperty />
</s:iTerator>
</s:iTerator>
#of.last is used at the last element that whether judgement drops currently; Last returns; of type of a BooleanFirst returns; of type of a Boolean
Key word of 4) , use Odd / Even
< ! - - odd travel shows for red, even travel shows for green- - >
<s:iTerator Value="days" Status="offset">
<s:eLse>
<s:iF Test="#offset.odd==True">
<li Style="color: Red" Mce_style="color: Red"><s:pRoperty /></li>
</s:iF>
<s:eLse>
<li><s:pRoperty /></li>
</s:eLse>
</s:eLse>
</s:iTerator>
< ! - - odd travel shows for red, even travel shows for green- - >
<s:iTerator Value="days" Status="offset">
<s:eLse>
<s:iF Test="#offset.odd==True">
<li Style="color: Red" Mce_style="color: Red"><s:pRoperty /></li>
</s:iF>
<s:eLse>
<li><s:pRoperty /></li>
</s:eLse>
</s:eLse>
</s:iTerator>
Below 5) , summary, when the Status attribute of statement Iterator, pass #statusName.method to be able to use the following method:
The 6) , usage that see next is in in Iterator call Value Stack finally again.
<s:iTerator Value="countries">
<s:iTerator Value="cities">
<s:pRoperty Value="name"/> , <s:pRoperty Value="[1].name"/><br>
</s:iTerator>
</s:iTerator>
<s:iTerator Value="countries">
<s:iTerator Value="cities">
<s:pRoperty Value="name"/> , <s:pRoperty Value="[1].name"/><br>
</s:iTerator>
</s:iTerator>
<ww:pRoperty Value="[1].name"/>Equal in value at <ww:pRoperty Value="[1].top.name"/>We Refer To A Specific Position On The Stack: '[1]' . The Top Of The Stack, position 0, contains The Current City, pushed On By The Inner Iterator; Position 1 Contains The Current Country, pushed There By The Outer Iterator. (City is in current inn, namely Top or [0] , and [1] shows palpability is outer Iterator object, namely Country)
'[n]' mark cites begin the position to be N child inn (Sub-stack) , is the target that positional N locates not just. Because this '[0]' represents whole inn, and '[1]' is all inn elements outside dividing Top target.
==========回复|reply==========
无
==========English==========
N/A<!-- //正文结束 -->
发表评论
-
Eclipse中jsp、js文件编辑时,卡死现象解决汇总
2016-03-01 11:36 703使用Eclipse编辑jsp、js文件时,经常出现卡死现象, ... -
转-HTTP cookies 详解
2015-03-29 14:35 719HTTP cookies,通常又称作"cookie ... -
<s:property />标签:是输出指定值用的标签。可以输出任何范围的值。
2012-03-24 13:37 852<s:property />标签:是输出指定值用的 ... -
如何解决“HTTP错误403-禁止访问”问题?
2012-03-20 18:18 5760100 Continue:初始的请求已经接受,客户应当继续发送 ... -
JSP 的301重定向服务端技术实现
2012-03-09 20:27 1103HttpServletRequest rq = (HttpS ... -
解决火狐不支持Cursor:hand的方法
2011-07-15 15:55 1207firefox 下cursor style="cur ... -
JavaScript中json对象和string对象之间的转化
2011-03-21 20:03 1301json对象 var json = {aa:true,bb:t ... -
服务器端包含,html文件不支持
2011-03-14 13:42 1714要在html包含文件,参考: 在宿主页面中嵌入外部页面 刘 ... -
Ext TabPanel items高度宽度自适应(续)
2011-01-30 10:52 4942经过努力调试,终于解 ... -
如何用photoshop输出html(div+css)网页
2011-01-28 21:21 905在修改好相应的文字与图象之后,我们就将PSD文件输出(X)HT ... -
IE7,ie8 ,火狐显示正常,ie6就乱码了解决方法
2011-01-15 14:14 5859最近又碰到了中文乱码问题,这里我没有把数据库牵扯进来,先说下我 ... -
CSS中的!important属性用法
2010-10-16 14:46 877关于CSS的运用技巧有很多, 今天主要探讨一下CSS中 !im ... -
position 的 static、relative、absolute、fixed、inherit
2010-10-11 13:51 1096网上也早有关于 position 的讲解,我个人觉得写得不全面 ... -
IE和Firefox中Javascript和CSS的区别
2010-10-11 12:18 10251. 对象 问题 1.1 Form对象 现有问题:现有代码 这 ... -
IOException while loading persisted sessions: java.io.EOFException
2010-09-29 18:44 691这个 异常一般是tomcat非正常关闭引起的,只要清除tomc ... -
浅谈javascript的分号
2010-08-25 16:56 991javascript的分号代表语句的结束符,但由于javasc ... -
关于createTextRange和createRange的一些用法
2010-08-23 20:05 1709一、返回createTextRange的text和htmlTe ... -
去掉输入中的空格 但是字符串中的光标位置不变
2010-08-23 20:04 1208<script type="text/java ... -
Struts2 Result-type(封装Action层到View层的跳转逻辑)(1)
2010-08-14 16:05 3697Struts2将Result列为一个独立的层次,可以说是整个S ... -
网站二级菜单演示代码
2010-08-14 08:43 1228<!DOCTYPE html PUBliC " ...
相关推荐
struts2中iterator 标签的使用详解
struts2 标签iterator使用我自己试过的
其实只有一点struts2 iterator标签遍历二维数组
struts2中siterator 标签的使用详解 及 OGNL用法 struts2中siterator 标签的使用详解 及 OGNL用法
struts2 中标签的使用 这段时间学习用struts2来开发网站,其中对一些struts2的标签在实际操作上有一些体会。 一.关于iterator迭代集合对象的问题:
NULL 博文链接:https://takeme.iteye.com/blog/1663239
可对struts2 标签如<iterator>等相应列进行求和.
struts2标签详解 Iterator
<%@ taglib uri="/struts-tags" prefix="s" %> 结合例子,重点掌握以下标签的用法 (1) (2) (3) <s:if> 、、 (4) <s:iterator> (5) (6) 、 (7) 、、、 (8) 、、<s:checkboxlist>
1.4 Web项目中使用Struts2初探 20 第2章 Web基础技术简介 31 2.1 B/S和C/S系统区别 31 2.2 JSP和Servlet介绍 32 2.3 XML知识介绍 34 第3章 Struts2核心技术 37 3.1 使用web.xml配置Struts2实现Web项目Struts2应用 37...
主要介绍Strus2中的通用标签,主要有, , , , , , <s:iterator>, , , 等几个标签的具体用法,希望能对大家有帮助。
该文档 主要描述struts2 常用的一些标签 帮助 对struts标签存在 疑惑的朋友更好更迅速的了解和学习
生成一个简单的iterator,并且使用iterator标签打印出内容。 ,bbb,ccc,ddd,eee'}"> <s:iterator> <s:property /><br/> </s:iterator> 例2: 生成一个iterator,使用count属性。因为count属性值为3,所以只有前...
9.1 为什么在Struts 2中使用Spring 196 9.1.1 依赖注入能做些什么 197 9.1.2 Spring如何管理对象和注入依赖 199 9.1.3 使用接口隐藏实现 200 9.2 将Spring添加到Struts 2 202 9.2.1 让Spring管理动作、拦截器和结果...
Struts 2 标签库(文档手册) Tags-API-CLSW-JSP <%@ taglib prefix="s" uri="/struts-tags" %> 就能使用struts2.0的标签库 下面就介绍每个标签的具体应用实例说明:按字母排列 A: 1. 2. <s:a href=""></s:a>-...
web开发struts2标签 <s:property></s:property> <s:iterator></s:iterator>
在action里面写了方法获取一个list,再将这个list的值放到jsp页面中显示出来,用的是<s:iterator>标签。
主要用于将多个集合拼成一个新的集合。它只有一个id参数。 需要和param标签同时使用。 一搬情况下append标签使用过后,iterator标签会同时使用。
本书是广受赞誉的Struts 2优秀教程,它全面而深入地阐述了Struts 2的各个特性,并指导开发人员如何根据遇到的问题对症下药,选择使用最合适的特性。作者处处从实战出发,在丰富的示例中直观地探讨了许多实用的技术,...
自己使用过的struts2标签总结 1. resList是action中的一个属性 <s:iterator id="rs" value="resList" status="count" > </s:iterator> <s:iterator id="pwd" value="#request.usePwdList" status="mIndex"> ...