javax.el.ELException:解析错误:“#{a4jSkin.imageUrl('buttonBackgroundImage.png')}”
javax.el.ELException: Error Parsing: "#{a4jSkin.imageUrl('buttonBackgroundImage.png')}"
我正在尝试在我的 JSF 2.1.29_01 项目中使用 RichFaces 4.5.2.Final,但它无法正常工作。我将以下皮肤参数添加到我的 web.xml
:
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>emeraldTown</param-value>
</context-param>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- Making the RichFaces skin spread to standard HTML controls -->
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
<param-value>true</param-value>
</context-param>
而且它不起作用。完全不起作用的是找不到 RichFaces 资源。它们插入最终的 HTML 输出如下:
<link type="text/css" rel="stylesheet" href="/JavaServerFaces
/org.richfaces.resources/javax.faces.resource/org.richfaces
/skinning.ecss?db=eAFL29S2EQAFbwJQ">
但事实上,它们并没有被应用,当我尝试访问资源时(输入
localhost:8080/JavaServerFaces
/org.richfaces.resources/javax.faces.resource/org.richfaces
/skinning.ecss?db=eAFL29S2EQAFbwJQtype
通过浏览器我得到 404。之后我尝试将 ResourceServlet
添加到我的 web.xml
中,如下所示:
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/org.richfaces.resources/*</url-pattern>
</servlet-mapping>
现在,当我尝试访问资源时,出现以下异常:
javax.el.ELException: Error Parsing: "#{a4jSkin.imageUrl('buttonBackgroundImage.png')}"
com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:124)
com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:141)
com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:185)
com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:65)
com.sun.faces.application.ApplicationImpl.evaluateExpressionGet(ApplicationImpl.java:426)
org.richfaces.resource.css.CSSVisitorImpl.visitStyleDeclaration(CSSVisitorImpl.java:219)
org.richfaces.resource.css.AbstractCSSVisitor.visitStyleRule(AbstractCSSVisitor.java:98)
org.richfaces.resource.css.AbstractCSSVisitor.visitRule(AbstractCSSVisitor.java:61)
org.richfaces.resource.css.AbstractCSSVisitor.visitStyleSheet(AbstractCSSVisitor.java:48)
org.richfaces.resource.CompiledCSSResource.getInputStream(CompiledCSSResource.java:124)
com.sun.faces.application.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:260)
org.richfaces.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:591)
org.richfaces.webapp.ResourceServlet.httpService(ResourceServlet.java:129)
org.richfaces.webapp.ResourceServlet.service(ResourceServlet.java:123)
root cause
com.sun.el.parser.ParseException: Encountered "(" at line 1, column 20.
Was expecting one of:
"}" ...
"." ...
"[" ...
">" ...
"gt" ...
"<" ...
"lt" ...
">=" ...
"ge" ...
"<=" ...
"le" ...
"==" ...
"eq" ...
"!=" ...
"ne" ...
"&&" ...
"and" ...
"||" ...
"or" ...
"*" ...
"+" ...
"-" ...
"?" ...
"/" ...
"div" ...
"%" ...
"mod" ...
com.sun.el.parser.ELParser.generateParseException(ELParser.java:1630)
com.sun.el.parser.ELParser.jj_consume_token(ELParser.java:1510)
com.sun.el.parser.ELParser.DeferredExpression(ELParser.java:113)
com.sun.el.parser.ELParser.CompositeExpression(ELParser.java:40)
com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:92)
com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:141)
com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:185)
com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:65)
com.sun.faces.application.ApplicationImpl.evaluateExpressionGet(ApplicationImpl.java:426)
org.richfaces.resource.css.CSSVisitorImpl.visitStyleDeclaration(CSSVisitorImpl.java:219)
org.richfaces.resource.css.AbstractCSSVisitor.visitStyleRule(AbstractCSSVisitor.java:98)
org.richfaces.resource.css.AbstractCSSVisitor.visitRule(AbstractCSSVisitor.java:61)
org.richfaces.resource.css.AbstractCSSVisitor.visitStyleSheet(AbstractCSSVisitor.java:48)
org.richfaces.resource.CompiledCSSResource.getInputStream(CompiledCSSResource.java:124)
com.sun.faces.application.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:260)
org.richfaces.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:591)
org.richfaces.webapp.ResourceServlet.httpService(ResourceServlet.java:129)
org.richfaces.webapp.ResourceServlet.service(ResourceServlet.java:123)
我该如何解决?
#{a4jSkin.imageUrl('buttonBackgroundImage.png')}
EL 2.2 之前不支持这种 EL 语法,通过该语法可以使用参数调用 bean 方法。这反过来表明您正在部署到 Servlet 2.5 / EL 2.1 容器或更早版本。
根据您之前的问题,我了解到至少升级到 Servlet 3.0 是不可能的。在这种情况下,您最好在支持给定 EL 2.2 语法的 webapp 中提供自定义 EL 2.1 实现,例如 JBoss EL.
另请参阅:
- Running JSF 2.0 on Servlet 2.4 container
- Invoke direct methods or methods with arguments / variables / parameters in EL
我正在尝试在我的 JSF 2.1.29_01 项目中使用 RichFaces 4.5.2.Final,但它无法正常工作。我将以下皮肤参数添加到我的 web.xml
:
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>emeraldTown</param-value>
</context-param>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- Making the RichFaces skin spread to standard HTML controls -->
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
<param-value>true</param-value>
</context-param>
而且它不起作用。完全不起作用的是找不到 RichFaces 资源。它们插入最终的 HTML 输出如下:
<link type="text/css" rel="stylesheet" href="/JavaServerFaces
/org.richfaces.resources/javax.faces.resource/org.richfaces
/skinning.ecss?db=eAFL29S2EQAFbwJQ">
但事实上,它们并没有被应用,当我尝试访问资源时(输入
localhost:8080/JavaServerFaces
/org.richfaces.resources/javax.faces.resource/org.richfaces
/skinning.ecss?db=eAFL29S2EQAFbwJQtype
通过浏览器我得到 404。之后我尝试将 ResourceServlet
添加到我的 web.xml
中,如下所示:
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/org.richfaces.resources/*</url-pattern>
</servlet-mapping>
现在,当我尝试访问资源时,出现以下异常:
javax.el.ELException: Error Parsing: "#{a4jSkin.imageUrl('buttonBackgroundImage.png')}"
com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:124)
com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:141)
com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:185)
com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:65)
com.sun.faces.application.ApplicationImpl.evaluateExpressionGet(ApplicationImpl.java:426)
org.richfaces.resource.css.CSSVisitorImpl.visitStyleDeclaration(CSSVisitorImpl.java:219)
org.richfaces.resource.css.AbstractCSSVisitor.visitStyleRule(AbstractCSSVisitor.java:98)
org.richfaces.resource.css.AbstractCSSVisitor.visitRule(AbstractCSSVisitor.java:61)
org.richfaces.resource.css.AbstractCSSVisitor.visitStyleSheet(AbstractCSSVisitor.java:48)
org.richfaces.resource.CompiledCSSResource.getInputStream(CompiledCSSResource.java:124)
com.sun.faces.application.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:260)
org.richfaces.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:591)
org.richfaces.webapp.ResourceServlet.httpService(ResourceServlet.java:129)
org.richfaces.webapp.ResourceServlet.service(ResourceServlet.java:123)
root cause
com.sun.el.parser.ParseException: Encountered "(" at line 1, column 20.
Was expecting one of:
"}" ...
"." ...
"[" ...
">" ...
"gt" ...
"<" ...
"lt" ...
">=" ...
"ge" ...
"<=" ...
"le" ...
"==" ...
"eq" ...
"!=" ...
"ne" ...
"&&" ...
"and" ...
"||" ...
"or" ...
"*" ...
"+" ...
"-" ...
"?" ...
"/" ...
"div" ...
"%" ...
"mod" ...
com.sun.el.parser.ELParser.generateParseException(ELParser.java:1630)
com.sun.el.parser.ELParser.jj_consume_token(ELParser.java:1510)
com.sun.el.parser.ELParser.DeferredExpression(ELParser.java:113)
com.sun.el.parser.ELParser.CompositeExpression(ELParser.java:40)
com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:92)
com.sun.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:141)
com.sun.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:185)
com.sun.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:65)
com.sun.faces.application.ApplicationImpl.evaluateExpressionGet(ApplicationImpl.java:426)
org.richfaces.resource.css.CSSVisitorImpl.visitStyleDeclaration(CSSVisitorImpl.java:219)
org.richfaces.resource.css.AbstractCSSVisitor.visitStyleRule(AbstractCSSVisitor.java:98)
org.richfaces.resource.css.AbstractCSSVisitor.visitRule(AbstractCSSVisitor.java:61)
org.richfaces.resource.css.AbstractCSSVisitor.visitStyleSheet(AbstractCSSVisitor.java:48)
org.richfaces.resource.CompiledCSSResource.getInputStream(CompiledCSSResource.java:124)
com.sun.faces.application.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:260)
org.richfaces.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:591)
org.richfaces.webapp.ResourceServlet.httpService(ResourceServlet.java:129)
org.richfaces.webapp.ResourceServlet.service(ResourceServlet.java:123)
我该如何解决?
#{a4jSkin.imageUrl('buttonBackgroundImage.png')}
EL 2.2 之前不支持这种 EL 语法,通过该语法可以使用参数调用 bean 方法。这反过来表明您正在部署到 Servlet 2.5 / EL 2.1 容器或更早版本。
根据您之前的问题,我了解到至少升级到 Servlet 3.0 是不可能的。在这种情况下,您最好在支持给定 EL 2.2 语法的 webapp 中提供自定义 EL 2.1 实现,例如 JBoss EL.
另请参阅:
- Running JSF 2.0 on Servlet 2.4 container
- Invoke direct methods or methods with arguments / variables / parameters in EL