我得到一个名单列表,我想将它们显示在(3)列中。 什么是使用jsp函数执行此操作的最佳方法?
列表:
apples oranges cherries limes pineapples grapefruits coconuts watermelons grapes bananas pears peaches预期产出 -
Column 1 - apples, oranges, cherries, and limes / Column 2 - pineapples, grapefruits, coconuts, and watermelons / Column 3 - grapes, bananas, pears, peaches可以说我想指定每列中有多少行,使用jsp函数执行此操作的最佳方法是什么?
另一种情况是,如果有一个包含13个项目的列表并按列数(3)划分,则会得到4.333333333 ..
我可以使用什么函数示例在第一列中获得6,在第二列中获得6,在第三列中获得1?
任何想法或评论,我真的很感激帮助......
I am getting a list of names and I would like to display them into (3) columns. Whats would be the best way to do this using a jsp function?
List:
apples oranges cherries limes pineapples grapefruits coconuts watermelons grapes bananas pears peachesExpected Output -
Column 1 - apples, oranges, cherries, and limes / Column 2 - pineapples, grapefruits, coconuts, and watermelons / Column 3 - grapes, bananas, pears, peachesLets say that I wanted to specify how many rows are in each column, what would be the best way to do this using a jsp function?
Another scenario would be, if there is a list of 13 items and you divide that by the number of columns (3), you would get 4.333333333..
What function example could I used to get 6 in the first column, 6 in the second column and 1 in the 3rd column?
Any thoughts or comments I would really be grateful for the help...
最满意答案
循环遍历您的集合,当添加6行添加新列时,您可以使用嵌套表,但首选div。
<c:forEach varStatus="count" var="fruit" items="${fruits}"> ... <c:when test=${count.index % 6 == 0}> //when loop count is multiple of six ... // create your column structure, be it, td, table or div </c:when> </c:forEach>Loop over your collection, when 6 rows added add a new column, you could use nested tables, but div's are preferred.
<c:forEach varStatus="count" var="fruit" items="${fruits}"> ... <c:when test=${count.index % 6 == 0}> //when loop count is multiple of six ... // create your column structure, be it, td, table or div </c:when> </c:forEach>更多推荐
发布评论