📄 iterators.jsp
字号:
<html><head><title>Iterator tests</title></head><body><%@ taglib uri="webwork" prefix="webwork" %><%@ taglib uri="webwork" prefix="iterator" %><webwork:bean name="'webwork.util.Timer'" id="timer"/><hr><H1>Testing null iterators and filters</H1>Testing null subset. Should be no output and no error but there will be a log statement:<br><iterator:subset source=""> <webwork:iterator> <webwork:property/><br> </webwork:iterator></iterator:subset>Time:<webwork:property value="@timer/time"/>ms<br><br>Testing null iterator. Should be no output and no error but there will be a log statement:<br><webwork:iterator value=""> <webwork:property/><br></webwork:iterator>Time:<webwork:property value="@timer/time"/>ms<br><br>Testing null generator. Should be no output and no error but there will be a log statement:<br><iterator:generator val="" count="5" id="xyzzy"/><webwork:iterator value="@xyzzy"> <webwork:property/><br></webwork:iterator>Time:<webwork:property value="@timer/time"/>ms<br><br><hr><H1>Testing iterator</H1><webwork:bean name="'webwork.util.Counter'"> <webwork:param name="'last'" value="10"/> <webwork:iterator> <webwork:property/><br> </webwork:iterator></webwork:bean>Time:<webwork:property value="@timer/time"/>ms<hr><H1>Testing iterator filters</H1>Numbers 1-10, start=0(=no filtering):<br><webwork:bean name="'webwork.util.Counter'"> <webwork:param name="'last'" value="10"/> <iterator:subset start="0"> <webwork:iterator> <webwork:property/><br> </webwork:iterator> </iterator:subset></webwork:bean>Time:<webwork:property value="@timer/time"/>msNumbers 1-10, start=4:<br><webwork:bean name="'webwork.util.Counter'"> <webwork:param name="'last'" value="10"/> <iterator:subset start="4"> <webwork:iterator> <webwork:property/><br> </webwork:iterator> </iterator:subset></webwork:bean>Time:<webwork:property value="@timer/time"/>ms<br>Numbers 1-20, start=10, count=5:<br><webwork:bean name="'webwork.util.Counter'"> <webwork:param name="'last'" value="20"/> <iterator:subset start="10" count="5"> <webwork:iterator> <webwork:property/><br> </webwork:iterator> </iterator:subset></webwork:bean>Time:<webwork:property value="@timer/time"/>ms<br>Numbers 1-20, start=10, count=30:<br><webwork:bean name="'webwork.util.Counter'"> <webwork:param name="'last'" value="20"/> <iterator:subset start="10" count="30"> <webwork:iterator> <webwork:property/><br> </webwork:iterator> </iterator:subset></webwork:bean>Time:<webwork:property value="@timer/time"/>ms<br>java.util.List as iterator:<br><webwork:action name="'AgeList'"> <iterator:subset source="ages" start="1" count="2"> <webwork:iterator> <webwork:property/><br> </webwork:iterator> </iterator:subset></webwork:action>Time:<webwork:property value="@timer/time"/>ms<br>Array as iterator:<br><webwork:action name="'BookList'"> <iterator:subset source="bookArray" start="2"> <webwork:iterator> <webwork:property value="title"/><br> </webwork:iterator> </iterator:subset></webwork:action>Time:<webwork:property value="@timer/time"/>ms<br>Three value generators with merge and subset limits:<br><iterator:generator val="'foo'" count="5" id="foo"/><iterator:generator val="'bar'" count="10" id="bar"/><iterator:generator val="'xyzzy'" count="5" id="xyzzy"/><iterator:merge> <webwork:param name="'source'" value="@foo"/> <webwork:param name="'source'" value="@bar"/> <webwork:param name="'source'" value="@xyzzy"/> <iterator:subset count="30"> <webwork:iterator status="'status'"> <webwork:property value="@status/count"/>:<webwork:property/><br> </webwork:iterator> </iterator:subset></iterator:merge>Time:<webwork:property value="@timer/time"/>ms<br>Three value generators with append and subset limits:<br><iterator:generator val="'f,o,o'" separator="','" count="5" id="foo"/><iterator:generator val="'bar'" count="5" id="bar"/><iterator:generator val="'xyzzy'" count="5" id="xyzzy"/><iterator:append> <webwork:param name="'source'" value="@foo"/> <webwork:param name="'source'" value="@bar"/> <webwork:param name="'source'" value="@xyzzy"/> <iterator:subset count="13"> <webwork:iterator status="'status'"> <webwork:property value="@status/count"/>:<webwork:property/><br> </webwork:iterator> </iterator:subset></iterator:append>Time:<webwork:property value="@timer/time"/>ms<br><hr><H1>Testing append, subset, and value generators</H1><table border="1"><webwork:bean name="'webwork.util.Counter'"> <webwork:param name="'last'" value="5"/><webwork:iterator id="colcount"><tr><iterator:generator val="'foo,bar,xyzzy'" separator="','" count="@colcount" id="values"/><iterator:generator val="' '" count="-1" id="space"/><iterator:append> <webwork:param name="'source'" value="@values"/> <webwork:param name="'source'" value="@space"/> <iterator:subset count="6"> <webwork:iterator> <td width=40><webwork:property/></td> </webwork:iterator> </iterator:subset></iterator:append></tr></webwork:iterator></table></webwork:bean>Time:<webwork:property value="@timer/time"/>ms<br><hr><H1>Testing iterator status</H1><webwork:bean name="'webwork.util.Counter'" id="rowcounter"> <webwork:param name="'first'" value="0"/> <webwork:param name="'last'" value="5"/></webwork:bean><table border="1"><webwork:iterator value="@rowcounter" status="'rowstatus'"><tr><webwork:bean name="'webwork.util.Counter'" id="colcounter"> <webwork:param name="'first'" value="0"/> <webwork:param name="'last'" value="5"/></webwork:bean><webwork:iterator value="@colcounter" status="'colstatus'"><webwork:if test="@rowstatus/first==true || @colstatus/first==true || @rowstatus/last==true"><th><webwork:property value="@colstatus/count"/></th></webwork:if><webwork:else><td><webwork:property/></td></webwork:else></webwork:iterator></tr></webwork:iterator></table>Time:<webwork:property value="@timer/time"/>ms<br><%-- modulus --%><p><webwork:bean name="'webwork.util.Counter'"> <webwork:param name="'last'" value="25"/> <webwork:iterator status="'status'"> <webwork:property/> <webwork:if test="@status/odd == true"> - Odd Number </webwork:if> <webwork:if test="@status/even == true"> - Even Number </webwork:if> <webwork:if test="@status/modulus(5) == 0"> - Modulus 5 </webwork:if> <br> </webwork:iterator></webwork:bean></p>Time:<webwork:property value="@timer/time"/>ms<hr><H1>Testing iterator sorting</H1><webwork:bean name="'webwork.util.Counter'" id="counter"> <webwork:param name="'first'" value="0"/> <webwork:param name="'last'" value="5"/></webwork:bean><webwork:bean name="'webwork.util.Sorter'" id="sorter"/>Ascending:<br><iterator:sort source="@counter" comparator="@sorter/ascending"><webwork:iterator><webwork:property/><br></webwork:iterator></iterator:sort><p><webwork:bean name="'webwork.util.Counter'" id="counter"> <webwork:param name="'first'" value="0"/> <webwork:param name="'last'" value="5"/></webwork:bean>Descending:<br><iterator:sort source="@counter" comparator="@sorter/descending"><webwork:iterator><webwork:property/><br></webwork:iterator></iterator:sort><p>Sorting strings:<br><iterator:generator val="'Rickard,Maurice,Hristo'" separator="','" id="names"/><iterator:sort source="@names" comparator="@sorter/ascending"><webwork:iterator><webwork:property/><br></webwork:iterator></iterator:sort><p>Sorting objects (books by title, ascending order):<br><webwork:action name="'BookList'" id="booklist"/><iterator:sort source="@booklist/books" comparator="@sorter/ascending('title')"><webwork:iterator><webwork:property value="title"/> (<webwork:property value="author"/>)<br></webwork:iterator></iterator:sort><p>Sorting objects (books by author, descending order):<br><webwork:action name="'BookList'" id="booklist"/><iterator:sort source="@booklist/books" comparator="@sorter/descending('author')"><webwork:iterator><webwork:property value="title"/> (<webwork:property value="author"/>)<br></webwork:iterator></iterator:sort><p>Time:<webwork:property value="@timer/time"/>ms<br>Total time:<webwork:property value="@timer/total"/>ms<br></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -