[英]javax.el.ELException: Could not find property actionMethod in class com.example.Bean
While deploying GAE + primefaces application, I got following error:在部署 GAE + primefaces 应用程序时,出现以下错误:
com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException: Error Rendering View[/CreateEmployee.xhtml]
javax.el.ELException: /CreateEmployee.xhtml: Could not find property saveEmployee in class com.fetchinglife.domain.data.dao.EmployeeRepositoryImpl
at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
Even saveEmployee
is already in EmployeeRepositoryImpl
class.甚至
saveEmployee
已经在EmployeeRepositoryImpl
类中。 How is this caused and how can I solve it?这是怎么引起的,我该如何解决? Are there any annotations which I have to put extra?
是否有任何我必须额外添加的注释?
Let's rephrase the exception in a general format in order to better understand the cause:让我们以通用格式重新表述异常,以便更好地理解原因:
javax.el.ELException: Could not find property doSomething in class com.example.Bean
javax.el.ELException:在类 com.example.Bean 中找不到属性 doSomething
This exception is literally trying to tell you that the Bean
class doesn't have the following method:这个异常实际上是想告诉你
Bean
类没有以下方法:
public SomeObject getDoSomething() {
return someObject;
}
(where SomeObject
is the type of the doSomething
property) (其中
SomeObject
是doSomething
属性的类型)
There are several causes for this.这有几个原因。
Given the fact that the property name is in your case actually a combination of a verb and noun, a resonable cause is you incorrectly bound an action method to an attribute of some JSF component which actually takes a value expression, not a method expression.鉴于属性名称在您的情况下实际上是动词和名词的组合,一个合理的原因是您错误地将操作方法绑定到某个实际上采用值表达式而不是方法表达式的 JSF 组件的属性。 Eg when you accidentally do
例如,当你不小心做
<h:commandButton value="#{bean.doSomething}">Save</h:commandButton>
or even甚至
<h:button value="Save" outcome="#{bean.doSomething}" />
instead of代替
<h:commandButton value="Save" action="#{bean.doSomething}" />
The latter would then expect the following method, which you probably actually have:后者然后会期望以下方法,您可能实际上拥有:
public String doSomething() {
// ...
return "nextpage";
}
(which can also be declared to return void
by the way) (顺便也可以声明为返回
void
)
Another probable cause is that the component is not interpreted as a real component at all, but as "plain text".另一个可能的原因是该组件根本没有被解释为真正的组件,而是作为“纯文本”。 In other words, when you remove the
action
attribute and then try to open the JSF page in browser, it'll now load fine, but you will see the whole component unparsed in the generated HTML output (which you can see via rightclick, View Source in browser).换句话说,当您删除
action
属性然后尝试在浏览器中打开 JSF 页面时,它现在可以正常加载,但是您将在生成的 HTML 输出中看到未解析的整个组件(您可以通过右键单击查看浏览器中的源)。
This can have several causes:这可能有多种原因:
The XML namespace of the component is wrong or missing.组件的 XML 命名空间错误或缺失。 Eg in case of PrimeFaces you accidentally used the old PrimeFaces 2.x URI while you're actually using PrimeFaces 3+.
例如,在 PrimeFaces 的情况下,您在实际使用 PrimeFaces 3+ 时不小心使用了旧的 PrimeFaces 2.x URI。
<html ... xmlns:p="http://primefaces.prime.com.tr/ui">
The XML namespace URI contains a typo. XML 命名空间 URI 包含一个错字。
<html ... xmlns:p="http://primefaecs.org/ui">
The XML namespace prefix does not match. XML 命名空间前缀不匹配。
<html ... xmlns:pf="http://primefaces.org/ui">
The XML namespace is totally missing. XML 命名空间完全缺失。
<html ...>
The component library is not installed at all.根本没有安装组件库。 In other words, the JARs containing component library's tag definitions is missing in webapp's
/WEB-INF/lib
folder.换句话说,webapp 的
/WEB-INF/lib
文件夹中缺少包含组件库标签定义的 JAR。
Either way, all <p:xxx>
tag won't be parsed and be considered as template text.无论哪种方式,所有
<p:xxx>
标签都不会被解析并被视为模板文本。 But, all EL expressions will still be evaluated (as if you're using <p>#{bean.text}</p>
), and they will all behave as ValueExpression
s instead of MethodExpression
s.但是,仍然会评估所有 EL 表达式(就像您使用
<p>#{bean.text}</p>
),并且它们都将表现为ValueExpression
而不是MethodExpression
。
An easy way to recognize the root cause is looking at stack trace.识别根本原因的一种简单方法是查看堆栈跟踪。 If you're seeing
com.sun.faces.facelets.compiler.AttributeInstruction
in the stack trace, then it means that the component is interpreted as "plain text".如果您在堆栈跟踪中看到
com.sun.faces.facelets.compiler.AttributeInstruction
,则表示该组件被解释为“纯文本”。 Otherwise you would have seen eg org.primefaces.component.commandbutton.CommandButton
in the specific case of <p:commandButton>
.否则你会在
<p:commandButton>
的特定情况下看到例如org.primefaces.component.commandbutton.CommandButton
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.