How to use JSTL <c: forEach> with Struts2 <s: url>?
I have this code that really works:
<s:iterator value="breadcrumb.links" var="link">
<s:url action='%{#link.url}' var="url" />
<li>
<a href="${url}">${link.name}</a>
</li>
</s:iterator>
How am I doing the same, but with c: foreach instead of s: iterator?
I tried:
<c:forEach items="${breadcrumb.links}" var="link">
<s:url action='${link.url}' var="url" />
<li>
<a href="${url}">${link.name}</a>
</li>
</c:forEach>
but I get the error:
According to the TLD or attribute directive in the tag file, the attribute action does not accept any expressions
Thankyou.
+4
1 answer
To be more comfortable with Struts2 tags and OGNL, read and tag this answer .
Struts2 OGNL ( EL, ), JSTL PageContext ( OGNL #attr.something), var:
<c:forEach items="${breadcrumb.links}" var="link">
<s:url action='%{#attr.link.url}' var="url" />
<li>
<a href="${url}">${link.name}</a>
</li>
</c:forEach>
OGNL:
#attr['foo']#attr.foo:PageContext, ,request/session/application
+6