Search code examples
struts2freemarker

Use status attribute from s:iterator inside freemarker template


So I have this jsp file where I use s:iterator because I have a list to display. Inside of the iterator, I included a ftl file. So basically:

<s:iterator value="list" status="userStatus">
    ...
    <s:include value="relation.ftl"/>
    ...
</s:iterator>

What I'd like to do is this : in the ftl file, I have an id but I'd like the id to be unique (generated dynamically). Is there a way to do that ?

I tried by typing id="%{#userStatus.index}" but doesn't seem to do the trick for the elements after the first one.

Thank you in advance


Solution

  • Finally I got the answer myself : I had to type

    ${userStatus.index}