javax.el.PropertyNotFoundException:Target Unreachable,标识符'registerBean'解析为空



我正在尝试在tomcat服务器上实现一个注册页面,但是未创建备用bean,当我单击"提交"按钮时,我会收到以下错误。

由:javax.el.propertynotfoundexception:目标无法达到 标识符" registerBean"已解决为null org.apache.el..parser.astvalue.gettarget(astvalue.java:98)at org.apache.el..parser.astvalue.getType(astvalue.java:82)at org.apache.el.valueexpresseximpl.getType(valueexpressionimpl.java:172) 在 com.sun.faces.facelets.el.tagvalueexpression.getType(tagvalueexpression.java:98)

这是registerbean.java

package com.please.beans;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

@Named
@SessionScoped
public class RegisterBean implements Serializable{
    private String emailAddress="3234234";
    private String userName;
    private String password;
    public String getEmailAddress() {
        return emailAddress;
    }
    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public void doLogin(){
        System.out.println("Test sucessful");
    }
}

这是Inbisup.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!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://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        Hello from Facelets
        <h:form>
            <h:outputText value="E-mail address" ></h:outputText>
            <h:inputText id="emailaddress" value="#{registerBean.emailAddress}" required="true"></h:inputText>
            <h:outputText value="Password"></h:outputText>
            <h:inputSecret id="password" value="#{registerBean.password}"></h:inputSecret>
            <h:outputText value="#{registerBean.emailAddress}"></h:outputText>
            <h:commandButton action="#{registerBean.doLogin()}"></h:commandButton>
        </h:form>
    </h:body>
</html>

更改注释如:

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name="registerBean")
@SessionScoped
public class RegisterBean implements Serializable{
//Your code here
..........................
}

相关内容

  • 没有找到相关文章

最新更新