java - JSF javax.el.PropertyNotFoundException : Target Unreachable, 标识符 'home' 解析为空

标签 java tomcat jsf-2

我的应用是cosist:

索引.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://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui">

<h:head>
    <title>Date Input of Users</title>
</h:head>

<body>

    <p:fieldset legend="name of home">

        <!-- form to insert a user data -->
        <h:form>

            <b>name of User:</b>
            <h:inputText value="#{home.name}"/><br/>

            <p:commandButton action="#{home.res}" ajax="false"      
                value="Save" />                                         <!-- button to save --> 
            <p />

        </h:form>


    </p:fieldset>

</body>

</html>

我的 bean 是->

package prova;

import javax.annotation.ManagedBean;
import javax.faces.bean.SessionScoped;

@SessionScoped
@ManagedBean

public class Home {

    //fields
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //change a page
    public String res(){
        return ("results");
    }
}

但是当单击保存按钮时,我的服务器 tomcat 返回错误而不是页面 错误是:

javax.el.PropertyNotFoundException: Target Unreachable, identifier 'home' resolved to null

谢谢大家,对不起我的英语

最佳答案

将该 bean 的导入更改为:

javax.faces.bean.ManagedBean;

另请参阅:

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

相关文章:

java - 将 &nbsp 作为字符串处理

java - 排行榜配置错误

tomcat - 如何更改hybris data hub的默认凭证

jsp - 通过 javamail 发送电子邮件时出现 NullPointer 异常

java - 带有表达式的 JSF 2.0 是一个方法错误

java - 如何使用 XFire 创建文档化的 WSDL

java - 在Java中打印数组的内容

java - 在 eclipse : SEVERE: ContainerBase. addChild : start: org. apache.catalina.LifecycleException 中获取错误:

jsf-2 - CDI @ConversationScoped 与 AJAX

java - JSF2 : selectOneMenu with custom selectItems: all items are selected