Jsf p:commandButton操作引发javax.el.PropertyNotFoundException

Jsf p:commandButton操作引发javax.el.PropertyNotFoundException,jsf,primefaces,propertynotfoundexception,methodexpression,Jsf,Primefaces,Propertynotfoundexception,Methodexpression,错误在于: javax.el.PropertyNotFoundException:/index.xhtml:在类型fya.beanpages.IndexBean上未找到属性“validar” 它似乎找不到validar方法。它认为这是一种属性 这是xhtml: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional

错误在于:

javax.el.PropertyNotFoundException:/index.xhtml:在类型fya.beanpages.IndexBean上未找到属性“validar”

它似乎找不到validar方法。它认为这是一种属性

这是xhtml:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui">

<h:head>  
  <title>FYA WEB</title>
</h:head>  

<h:body>  
    <ui:composition template="/base/base.xhtml">
    <ui:param name="title" value="FYA Web Login"/>
        <ui:define name="content">
            <h:form id="form">  
                <p:panel id="panel" header="Inicio Sesión">  
                    <p:messages id="panelmsg"/>  

                    <h:panelGrid columns="3">  
                        <h:outputLabel for="nomUsuario" value="Usuario: *" />  
                        <p:inputText id="nomUsuario" value="#{login.usu.nomusuario}" required="true" label="Usuario"/>

                        <h:outputLabel for="pwdUsuario" value="Contraseña: *" />  
                        <p:password id="pwdUsuario" value="#{login.usu.contraseña}" label="Contraseña" required="true"/>  
                    </h:panelGrid>  

                    <p:commandButton id="btnIniciar" value="Iniciar Sesión" action="#{login.validar}" update="panelmsg" ajax="true"/>  
                </p:panel>  
            </h:form>
        </ui:define>
    </ui:composition>        
</h:body>

也许我觉得我做错了什么,你能帮我吗?

如果你没有正确安装PrimeFaces,可能会发生这种情况。这样,所有的
标记都被视为模板文本(也就是说,Facelets不会将它们解析为JSF组件,而是直接打印到HTML输出)。模板文本中的所有EL表达式默认解析为属性值表达式(如
blah{bean.foo}blah

),这需要getter方法。所有最初表示方法表达式的EL表达式都会抛出这个异常,因为在bean中找不到getter

要正确安装PrimeFaces,请确保JAR文件位于webapp的
/WEB-INF/lib
(如果您使用的是Eclipse之类的IDE,请确保绝对不要触碰构建路径设置,如果您在不小心尝试解决它时在那里乱摆弄,请全部撤消!),并确保项目已正确重建,服务器的工作文件夹已正确清理,服务器中的部署确实在正确的位置包含PrimeFaces JAR文件


另一件需要考虑的事情是tagliburi
http://primefaces.org/ui
是在PrimeFaces 3.0中引入的。因此,如果您碰巧有一罐PrimeFaces2.x或更旧的,那么您也可以完全面对这个问题。您需要将PrimeFaces升级到至少3.0,或者退回到使用2.x兼容的标记库URI
http://primefaces.prime.com.tr/ui

我认为本[教程]()对您有帮助非常感谢,我配置了构建路径设置,还使用了较旧版本的PrimeFaces。
package pe.edu.cibertec.managed;
@ManagedBean(name="login")
public class LoginBean {

private Usuario usuario=new Usuario();
private static LoginService loginService= new LoginServiceImpl();

public Usuario getUsuario() {
    return usuario;
}

public void setUsuario(Usuario usuario) {
    this.usuario = usuario;
}

public String validar() throws Exception {
    if(loginService.validar(usuario))
        return "paginas/principal";
    else{
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Datos Incorrectos"));
        return null;
    }
}


}