Reputation: 45485
In an struts 2 project I get the ognl warning while doing a loop like this:
<c:set var="unitArray" value="${fn:split(unit, ',')}" />
<c:forTokens items="${key}" delims="," var="name" varStatus="counter">
<s:text name="%{#attr.unitArray[#attr.counter.index]}" />
</c:forTokens>
The warning is
Package of target [javax.servlet.jsp.jstl.core.LoopTagSupport$1Status@353a1d92] or
package of member [public int javax.servlet.jsp.jstl.core.LoopTagSupport$1Status.getIndex()] are excluded!
Can this be solved?!
Upvotes: 1
Views: 1217
Reputation: 1
You can put the status variable's value to the value stack and use it instead of JSTL tag's status index.
<c:forTokens items="${key}" delims="," var="name" varStatus="counter">
<s:set var="idx">${counter.index}</set>
<s:text name="%{#attr.unitArray[#idx]}" />
</c:forTokens>
Or use the opposite manipulation, just put the action to the page context and use its text property in <c:out>
. I didn't use this approach but you can try.
Upvotes: 1