struts2 jstl迭代器标记 [英] struts2 jstl iterator tag

查看:144
本文介绍了struts2 jstl迭代器标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找如何在struts2 jstl中实现一个东西,但我找不到方法。

I have been looking how to implement a thing in struts2 jstl but it is impossible for me to find the way.

当我从动作加载jsp页面时,我有一个字符串列表列表。

When I load the jsp page from the action, I have a list of String lists.

我想创建div作为元素有列表,但在每个div中,我想创建链接作为第三个子列表的元素。

I want to create as divs as elements have the list, but inside every div, I want to create as links as the third element of the sub-list.

所以我使用s:iterator标签来解析列表。但是我不知道如何在第一个迭代器中迭代$ {item [2]}。

So I use the s:iterator tag to parse the list. But I don't know how to iterate "${item[2]}" times inside the first iterator.

代码将是这样的:

<s:iterator value="functions" var="item" status="stat">
        <span class="operation">${item[1]}</span>
        <div id="${item[0]}">
            <s:for var $i=0;$i<${item[2]};$i++>
                <a href="#" id="link_$i">Link $i</a>
            </s:for>
        </div>
</s:iterator>

我在哪里放了s:for tag是我要迭代的地方$ {item [ 2]}次...

Where I have put the s:for tag is where I would like to iterate "${item[2]}" times...

任何人都可以帮助我吗?

Anyone can help me?

非常感谢您提前,
Aleix

Thank you very much in advance, Aleix

推荐答案

确保您的JSP页面中有JSTL核心库:

Make sure you've got the JSTL core library in scope in your JSP page:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

只需使用< c:forEach> 。这样的事情:

And simply use <c:forEach>. Something like this:

<c:forEach var="i" begin="0" end="${item[2] - 1}">
    <a href="#" id="link_${i}">Link ${i}</a>
</c:forEach>

这篇关于struts2 jstl迭代器标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆