我的应用程序是cosist:
index.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是 - &gt;
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
感谢所有人,对不起我的英语
答案 0 :(得分:0)
将该bean的导入更改为:
javax.faces.bean.ManagedBean;
另见: