javax.el.E​​LException:错误解析:"#{a4jSkin.imageUrl(' buttonBackgroundImage.png')}"

时间:2015-02-16 06:19:19

标签: jsf jsf-2 richfaces

我正在尝试在我的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)

我该如何解决?

1 个答案:

答案 0 :(得分:2)

#{a4jSkin.imageUrl('buttonBackgroundImage.png')}

在EL 2.2之前,不支持使用参数调用bean方法的EL语法。这反过来暗示您正在部署到Servlet 2.5 / EL 2.1容器或更早版本。

根据您之前的问题,我认为至少升级到Servlet 3.0是不可能的。在这种情况下,您最好在webapp上提供自定义EL 2.1实现,该实现支持给定的EL 2.2语法,例如JBoss EL。

另见: