org.apache.el.parser.ParseException: Encountered “(” at line X, column Y. Was expecting one of […]

前端 未结 1 714
日久生厌
日久生厌 2020-12-19 18:46

The below JSF snippet:


Throws this exception:

Encountered \         


        
相关标签:
1条回答
  • 2020-12-19 19:16

    That can happen if your environment doesn't support EL 2.2. Invoking direct methods with parentheses/arguments like this

    value="#{userbean.getAll()}" 
    

    is only supported since EL 2.2, which goes hand in hand with Servlet 3.0. If you're getting this exception, then that can only mean that you're not deploying to a Servlet 3.0 compatible container, or that your webapp's web.xml is not declared conform Servlet 3.0, or that your webapp's /WEB-INF/lib is littered with arbitrarily downloaded servletcontainer-specific JAR files originating from a completely different servletcontainer make/version which doesn't comply EL 2.2.

    There are basically 2 solutions:

    1. Use EL 2.1 compatible syntax, this works on Servlet 2.5 compatible containers:

       value="#{userbean.all}" 
      
    2. Upgrade to a Servlet 3.0 compatible container (Tomcat 7, Glassfish 3, JBoss AS 6, etc), or fix your web.xml to comply Servlet 3.0.

    You should also make absolutely sure that your webapp's /WEB-INF/lib does not contain any servletcontainer-specific libraries such as el-api.jar and friends (see also this related question).

    Please note that this is not a JSF problem at all. You got an exception from javax.el/org.apache.el package, not from javax.faces/com.sun.faces package. This means that it's an EL problem. It's basically saying that your EL syntax is wrong. It encountered an ( where it didn't expect that. The expected characters/operators are clearly listed thereafter.

    See also:

    • Invoke direct methods or methods with arguments / variables / parameters in EL
    • How to call a method with a parameter in JSF
    • Our EL wiki page
    0 讨论(0)
提交回复
热议问题