我可以在struts2.0中的jsp迭代器中使用迭代器吗?

发布于 2024-09-13 21:41:31 字数 488 浏览 2 评论 0原文

中定义的 ArrayList

private ArrayList<LocWiseSaleParam> locWiseSaleList;

where LocWiseSaleParam is myaction class

这是我在 jsp 上使用迭代器并访问其值 。但我可以使用与嵌套迭代器具有相同值的迭代器吗?

<s:iterator value="locWiseSaleList" id="list" >
           <s:iterator value="locWiseSaleList" id="list" >
                 <s:property value="productName"/>
           </s:iterator>
</s:iterator>

需要这样做,因为我正在 jsp 上创建表格结构

This is the ArrayList defined in the

private ArrayList<LocWiseSaleParam> locWiseSaleList;

where LocWiseSaleParam is myaction class

I am using a iterator on jsp and accessing its values. but can i use the iterator with the same value as nested iterator

<s:iterator value="locWiseSaleList" id="list" >
           <s:iterator value="locWiseSaleList" id="list" >
                 <s:property value="productName"/>
           </s:iterator>
</s:iterator>

It is needed to do becausse i am creating a tabular structure on jsp

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

意中人 2024-09-20 21:41:31
<s:iterator value="locWiseSaleList" id="parent" stratus="id">
  <s:iterator value="locWiseSaleList{parent.id}">
      <s:property value="#parent.productName"/> //this will give value of parent iterator
      <s:property value="productName"/>         //this will give value of the child iterator
  </s:iterator>
</s:iterator>
<s:iterator value="locWiseSaleList" id="parent" stratus="id">
  <s:iterator value="locWiseSaleList{parent.id}">
      <s:property value="#parent.productName"/> //this will give value of parent iterator
      <s:property value="productName"/>         //this will give value of the child iterator
  </s:iterator>
</s:iterator>
我的黑色迷你裙 2024-09-20 21:41:31

我想你需要这个

<s:iterator value="locWiseSaleList" id="parent">
  <s:iterator value="locWiseSaleList">
      <s:property value="#parent.productName"/> //this will give value of parent iterator
      <s:property value="productName"/>         //this will give value of the child iterator
  </s:iterator>
</s:iterator>

啊,我没有注意到这篇文章太旧了

I guess you need this

<s:iterator value="locWiseSaleList" id="parent">
  <s:iterator value="locWiseSaleList">
      <s:property value="#parent.productName"/> //this will give value of parent iterator
      <s:property value="productName"/>         //this will give value of the child iterator
  </s:iterator>
</s:iterator>

AAh,i didnt notice this post is too old

相守太难 2024-09-20 21:41:31

这应该有效。嵌套迭代器将向值堆栈询问名为“locWiseSaleList”的顶部可迭代对象,它应该找到相同的对象。我不确定每次调用是否都会生成一个新的迭代器,但我猜是这样,然后它应该可以工作。

你为什么不尝试一下呢?

This should work. The nested iterator will ask the value stack for the top named iterable "locWiseSaleList" and it should find the same object. I'm not sure if a new iterator is generated on each call, but I guess it is, and then it should work.

Why don't you just try it?

神回复 2024-09-20 21:41:31

我也得到了类似的要求,下面的一个工作

<s:set var="temp" value="locWiseSaleList"/>
<s:iterator value="locWiseSaleList" var="i" >
       <s:iterator value="temp" var="j" >
             ${i.productName} ${j.productName} 
       </s:iterator>
</s:iterator>

你可以使用 i 和 j 以及正常的循环计数器变量,但这里 i,j 将保存你的 LocWiseSaleParam 对象。

我们的 s:set 语句将创建列表的副本。

I also got the similar requirement and below one worked

<s:set var="temp" value="locWiseSaleList"/>
<s:iterator value="locWiseSaleList" var="i" >
       <s:iterator value="temp" var="j" >
             ${i.productName} ${j.productName} 
       </s:iterator>
</s:iterator>

you can use i and j and normal loop counter variables but here i, j will hold your LocWiseSaleParam object.

and our s:set statement will create a copy of list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文