支持哪种版本的EL设置和列表?我正在尝试用Java Expression Language
定义一组数据${{"cat", "dog", "giraffe"}}
我得到以下异常:
javax.el.ELException: Failed to parse the expression [${{"cat", "dog", "giraffe"}]
org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:146)
org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:172)
org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:217)
org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:67)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:1025)
org.apache.jsp.user_jsp._jspService(user_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
答案 0 :(得分:1)
Expression Language 3.0支持列表,集和地图。 Tomcat 7.0仅支持EL 2.2。这就是我的脚本不起作用的原因。
答案 1 :(得分:0)
您使用的是哪个容器?这是在我的Tomcat 8中运行的演示代码。
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<c:set var="animalList" value='${["cat","dog","giraffe"]}'/>
<html>
<body>
<c:forEach items="${animalList}" var="animal">
${animal}
</c:forEach>
</body>
</html>