javax.el.ELException: Failed to parse the expression [{pz:instanceof(object,'com.project.domain.MyClass')}]

前端 未结 4 903
闹比i
闹比i 2020-12-10 06:44

Currenty I have a web project with JSF 1.2 and Facelets running in tomcat 6.0.18.0. I decided to upgrade the servlet container, thus i deployed in tomcat 7 and all seemed ok

4条回答
  •  忘掉有多难
    2020-12-10 07:28

    This is actually a misleading exception. It has a different underlying cause. The function name instanceof is invalid.

    The EL 2.2 specification says the following:

    1.14 Reserved Words

    The following words are reserved for the language and must not be used as identifiers.

        and   eq     gt     true   instanceof
        or    ne     le     false  empty
        not   lt     ge     null   div        mod
    

    Note that many of these words are not in the language now, but they may be in the future, so developers must avoid using these words.

    and

    1.19 Collected Syntax

    ...

    Identifier ::= Java language identifier
    

    ...

    Where the Java language identifier stands for keywords like instanceof, if, while, class, return, static, new, etc. They may not be used as variable/function names in EL. In case you have properties with those names, use the brace notation instead like so #{bean['class'].simpleName} instead of #{bean.class.simpleName}.

    This was been fixed in Tomcat 7.0.4 or somewhere near before this version as indicated by issue 50147 wherein someone else pointed out the same problem as you have. So, to solve your problem, you have to rename your EL function name to for example isInstanceOf or something.

提交回复
热议问题