views:

1687

answers:

1

Can someone explain to me why the following code results in the error: According to TLD or attribute directive in tag file, attribute value does not accept any expressions. It always breaks whenever I am trying to set the value dynamically for the parameter of the URL.

`<%@ page contentType="text/html; charset=UTF-8" %>`

<%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:forEach var="v" items="${files}"> ${v} <a href='<s:url action="DeleteFile"><s:param name="fileName" value="${v}" />'>Delete
</c:forEach>

I'm using Struts 2 and the latest version of Java. Any help would be appreciated.

+2  A: 

You are mixing JSTL tags (the foreach) and Struts tags (the s param). Although it is possible to make them work together, why get into trouble?

Use the struts iterator tag and dump the foreach.

See details at http://struts.apache.org/2.0.14/docs/iterator.html

In theory everything that can be done with JSTL is possible with native struts 2 tags, so your application should probably not need JSTL at all.

kazanaki