Struts 2中的每一步如何做

编程入门 行业动态 更新时间:2024-10-23 21:25:27
本文介绍了Struts 2中的每一步如何做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试为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 < ul class =slider> < li> 更好的方法:

< ul class =slider> < li> 在CSS中(或在< style>< / style> ; < head> 元素中的块)

ul.slider> li> p { text-align:center; 颜色:#151B54; font-weight:bold; background-color:#ddd; }

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中的每一步如何做

本文发布于:2023-11-26 21:19:35,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何做   Struts

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!