未找到属性的异常



我有以下html文件:

<h:body>
    <h:form id="loginForm">
        <p:growl id="msg" showDetail="true" life="3000" />
        <p:panel header="Login" style="width: 360px;">
            <h:panelGrid id="loginPanel" columns="2">
                <h:outputText value="Username" />
                <p:inputText id="username" value="#{loginBean.uname}" ></p:inputText>
                <p:spacer></p:spacer>
                <p:message for="username" ></p:message>
                <h:outputText value="Password" />
                <p:password id="password" value="#{loginBean.password}"  feedback="false"></p:password>
                <p:spacer></p:spacer>
                <p:message for="password"></p:message>
                <p:spacer></p:spacer>
                <p:commandButton action="#{loginBean.loginPro}" value="Login" update="loginForm" ajax="true"></p:commandButton>
            </h:panelGrid>
        </p:panel>
    </h:form>
</h:body>

LoginBean如下所示:

@ManagedBean(name = "loginBean")
@SessionScoped
public class LoginBean implements Serializable {
    private static final long serialVersionUID = 1L;
    private String uname;
    private String password;

    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getUname() {
        return uname;
    }
    public void setUname(String uname) {
        this.uname = uname;
    }
    public String loginPro() {
        boolean result = false;
        try {
            result = UserDAO.login(uname, password);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if (result) {
            return "home";
        } else {
            FacesContext.getCurrentInstance().addMessage(
                    null,
                    new FacesMessage(FacesMessage.SEVERITY_WARN,
                            "Invalid Login!",
                            "Please Try Again!"));
            return "login";
        }
    }

我一直收到以下消息,即使loginPro方法存在于LoginBean上:

javax.servlet。ServletException:/index.xhtml:在类型bean上找不到属性'loginPro'。LoginBeanjavax.faces.webapp.FacesServlet.service (FacesServlet.java: 659)org.apache.tomcat.websocket.server.WsFilter.doFilter (WsFilter.java: 52)

的意见吗?

try loginBean.loginPro()

与loginBean

。loginPro u说有一个属性变量get/set

我遇到了同样的问题,并在开头添加了下面的代码片段

            <!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:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">

相关内容

  • 没有找到相关文章

最新更新