Search code examples
jspstruts2jstlognlvaluestack

Struts 2 ognl.SecurityMemberAccess warning


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?!


Solution

  • 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.