<%pageContext.setAttribute("list",Arrays.asList("a","bc","d","ef"));%>
<c:forEach items="${list}" var="ele"> ${ele}] </c:forEach>
运行时出现“attribute [items] does not accept any expressions”错误,而当将${list}单独拿出运行却一切正常,说明EL没有问题。
后经过多次尝试发现问题在于标签处:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
将其改为:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
后,运行正常,版本过低的问题。
希望能够提供帮助!