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

标签 jsf tomcat cdi propertynotfoundexception

<分区>

我正在尝试在 Tomcat 服务器上实现一个注册页面,但是没有创建支持 bean,当我单击提交按钮时出现以下错误。

Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'registerBean' resolved to null at org.apache.el.parser.AstValue.getTarget(AstValue.java:98) at org.apache.el.parser.AstValue.getType(AstValue.java:82) at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:172) at 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");

    }

}

这里是signup.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
..........................
}

关于jsf - javax.el.PropertyNotFoundException : Target Unreachable, 标识符 'registerBean' 解析为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21242435/

相关文章:

java - 在没有 Tomcat 管理器的情况下从 jenkins 自动部署 war 文件

ejb - @专门针对EJB

Hibernate代理继承问题

tomcat - @javax.inject.Singleton 在 tomcat7.0.47 中不起作用

java - 手机正则表达式

jsf - 如何隐藏富人 :modalPanel on Ajax response in JSF

java - 只读微调器

jquery - 使用 jQuery 打开和关闭 richfaces 模式面板

java - 在 Apache Tomcat 中多次调用 REST 服务构造函数

tomcat - CAS 3.4.12.1 中的页面未正确重定向错误