我正在尝试为HTML中的网页构建滑块。 它从struts动作获取来自ArrayList(名为testList)的值。我希望在这个模式中同时显示列表中的6个值。例如:
如果数组的大小为26,{0, 1,2,3,4,5}然后{6,7,8,9,10,11}然后{11,12,13,14,15}等等直到{24,25},其余值即使它为空也没关系。
类似于每个循环: for(i = 0; i< size; i + 6 ){}
但是现在我从这个模式列表中获得值:
{0,1,2,3,4,5}然后{1,2,3,4,5,6}然后{2,3,4,5,6,7} ..这是因为索引(#status.index)按以下模式迭代{0,1,2,3 ...} 我希望索引增加6每次而不是0到1到2等。
我添加了step =6,但这不起作用。
以下是我的代码示例:
< ul class =slider>为什么1337迭代器而不是单个迭代器?为什么< b> ,< font> 等而不是使用CSS?
顺便说一句,您只需使用%(模块运算符)来检查当前位置是否是六的倍数;如果是,则需要拆分< li> ;
请注意 IteratorStatus.count 与 IteratorStatus.index + 1 相同,因为它基于 1 $ c $ 丑陋的方式:
< ul class =slider> < li>
I am trying to build a slider for a web page in HTML. Which gets values from an ArrayList(named testList) from a struts action. And I want to display 6 values from the list at a time in this pattern.for ex:
If the array is of size 26, {0,1,2,3,4,5} then {6,7,8,9,10,11} then {11,12,13,14,15} .. and so on upto {24,25} ,rest values even if null its ok.
Something like for each loops: for(i=0;i<size;i+6){}
But currently I get the values from the list in this pattern :
{0,1,2,3,4,5} then {1,2,3,4,5,6} then {2,3,4,5,6,7} ..
Which is because the index(#status.index)iterates in the following pattern {0,1,2,3...} I want the index to increment by 6 everytime instead of 0 to 1 to 2 etc.
I added step="6" , but this is not working.
Here is a sample of my code below:
<ul class="slider"> <s:iterator step="6" status="status" value="testList" > <li> <!-- FIRST SLOT OF DATA --> <div class="rightSubContainer"> <s:iterator value="testList[#status.index]" > <table > <tr> <th> <p align="center"><b ><font color="#151B54"><s:property value="name" /></font></b></p> </th> </tr> </table> <!-- ...values --> </s:iterator> </div> <div class="rightSubContainer"> <s:iterator value="testList[#status.index+1] " > <table > <tr> <th> <p align="center"><b ><font color="#151B54"><s:property value="name" /></font></b></p> </th> </tr> </table> <!-- ...values --> </s:iterator> </div> <div class="rightSubContainer"> <s:iterator value="testList[#status.index+2]" > <table > <tr> <th> <p align="center"><b ><font color="#151B54"><s:property value="name" /></font></b></p> </th> </tr> </table> <!-- ...values --> </s:iterator> </div> <!-- ... and so on.. upto 6 values -->解决方案
Why one table for each value ? Why 1337 iterators instead of a single one ? Why <b>, <font> etc instead of using CSS ?
By the way you simply need to use the % (module operator) to check if the current position is a multiple of six; if it is, you need to split the <li>;
Note that IteratorStatus.count is the same as IteratorStatus.index + 1, because it is 1-based;
Ugly way:
<ul class="slider"> <li> <s:iterator status="status" value="testList" > <table > <tr> <th> <p align="center"><b ><font color="#151B54"> <s:property value="name" /> </font></b></p> </th> </tr> </table> <s:if test="%{#status.count % 6 == 0}" > </li> <li> </s:if> </s:iterator> </li> </ul>Better way:
<ul class="slider"> <li> <s:iterator status="status" value="testList" > <p> <s:property value="name" /> </p> <s:if test="%{#status.count % 6 == 0}" > </li> <li> </s:if> </s:iterator> </li> </ul>and in CSS (or inside a <style></style> block in the <head> element)
ul.slider > li > p { text-align: center; color: #151B54; font-weight: bold; background-color: #ddd; }
更多推荐
Struts 2中的每一步如何做
发布评论