开发者

How To Generate unique HTML id attributes within Struts 2 iterator tag

开发者 https://www.devze.com 2023-02-13 11:26 出处:网络
I need to generate unique id attributes within the struts iterator on the lines of <div id=\"divId1\"/>

I need to generate unique id attributes within the struts iterator on the lines of

<div id="divId1"/>
<div id="divId2"/>
 etc, etc.

I've tried

<s:iterator value="myListFunction" status="#status">
    <s:set va开发者_StackOverflow中文版r="uniqueId" value="divId#status.count/>
    <s:div id="%{uniqueId}/>
</s:iterator>

and variations of the above, but nothing seems to work. Could someone point me in the right direction please


Try this:

<s:iterator value="myListFunction" status="status">
    <s:div id="divId%{#status.count}/>
</s:iterator>


Did you try (not tested):

<s:iterator value="myListFunction" status="status">
  <s:div id='%{"divId" + #status.count}'/>
</s:iterator>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号