javax.el.E​​LException:无法解析表达式[{pz:instanceof(object,'com.project.domain.MyClass')}] [英] javax.el.ELException: Failed to parse the expression [{pz:instanceof(object,'com.project.domain.MyClass')}]

查看:95
本文介绍了javax.el.E​​LException:无法解析表达式[{pz:instanceof(object,'com.project.domain.MyClass')}]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我有一个Web项目,其中包含在Tomcat 6.0.18.0中运行的JSF 1.2和Facelets.我决定升级servlet容器,因此我将其部署在tomcat 7中,直到我们使用自定义界面功能击中一个视图之前,一切似乎都还可以.

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 until we hit one view using my custome facelet functions.

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

Caused by: org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1, column 5. Was expecting one of:
"}" ...
"." ...
"[" ...

解析以下代码时,会发生此错误:

This error occurs when parsing the following code:

<ui:repeat var="object" value="#{objects}">
<ui:fragment rendered="#{pz:instanceof(object,'com.project.domain.MyClass')}">
...

如果我正确理解,由于表达式中的冒号,将引发错误.我已将其跟踪到tomcat/lib目录中随附的jasper-el,如果我用tomcat 6.0.18中的替换jasper.jar和jasper-el.jar,那么一切都可以正常工作.

If i understand correctly it throws an error because of the colon in the expression . I have tracked it down to the jasper-el that come with in the tomcat/lib directory, and if I replace jasper.jar and jasper-el.jar with the ones from tomcat 6.0.18 everythign works well.

在升级他们的雄猫之前,还有其他人有这个问题吗?以及他们如何解决呢? 我可以使用tomcat 6中的这些碧玉罐将其部署到生产tomcat 7中,还是可能引起更多问题.

Has anyone else had this problem before upgrading their tomcat? And How did they resolve it? Could I deploy in production tomcat 7 with these jasper jar from tomcat 6, or could this cause further problems.

推荐答案

这实际上是一个令人误解的异常.它具有不同的根本原因.函数名称instanceof无效.

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

EL 2.2规范表示以下内容:

1.14保留字

以下单词是该语言的保留字,不得用作 标识符.

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.

1.19收集的语法

...

1.19 Collected Syntax

...

Identifier ::= Java language identifier

...

Java语言标识符代表诸如instanceofifwhileclassreturnstaticnew等的关键字.它们不能用作变量/EL中的函数名称.如果您拥有具有这些名称的属性,请改为使用大括号表示法,例如#{bean['class'].simpleName}而不是#{bean.class.simpleName}.

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}.

此问题已在Tomcat 7.0.4或此版本之前的某个位置修复,如

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.

这篇关于javax.el.E​​LException:无法解析表达式[{pz:instanceof(object,'com.project.domain.MyClass')}]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆