user384241
user384241

Reputation: 559

Problem: "[action]" does not accept any expressions

I tried to use the following code :

<li>
    <% for (int i=0; i<parentList.size(); i++) {
        Role p = parentList.get(i); 
    %>
        <li><a href="<s:url action="<%=p.getFunclink() %>"/>"><%=p.getFuncname() %></a>
        <ul>
            <% for (int j=0; j<roleList.size(); j++) {
                Role c = roleList.get(j);
                if (!c.getFuncid().equalsIgnoreCase(c.getParentfunc()) && c.getParentfunc().equalsIgnoreCase(p.getFuncid()))
                {
                %>
                    <li><a href="<s:url action="<%=c.getFunclink() %>"/>"><%=c.getFuncname() %></a>                     
                <%
                }
            }   
            %>
        </ul>
    <% } %>
    </li>

but it throw error:

    JSPG0227E: Exception caught while translating /menu.jsp:  
/menu.jsp(95,17) --> JSPG0124E: According to TLD or attribute directive in tag file, attribute "[action]" does not accept any expressions. Value of expression is: "[%=p.getFunclink() %]".

How can i fix it? Thanks!

Upvotes: 1

Views: 1513

Answers (1)

Steven Benitez
Steven Benitez

Reputation: 11055

The Struts tags cannot accept expressions, thus:

<s:url action="<%=p.getFunclink() %>"/>

is invalid.

  • First, avoid using scriptlets at all.
  • Second, look into using the <s:iterator/> tag to iterate over your collections.

Upvotes: 2

Related Questions