我是JSF的新手,無法弄清楚發生了什麼。
我不斷收到此錯誤:/index.xhtml @ 12,80值=「#{} LoginBean.username」:目標不可達,標識符「LoginBean」解析爲空JSF:/index.xhtml @ 12,80 value =「#{LoginBean.username}」:目標無法訪問,標識符'LoginBean'解析爲空
我已經分離出的問題降到這個...
的index.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>JSF 2.0 LoginApp</title>
</h:head>
<h:body>
<h2>JSF 2.0 Login App</h2><br/>
<h:form>
Username: <h:inputText id="username" value="#{LoginBean.username}"> //error here
</h:inputText> <br/><br/>
Password: <h:inputSecret id="password" value="#{LoginBean.password}"> //and error here
</h:inputSecret> <br/><br/>
<h:commandButton action="response.xhtml" value="Login" type="Submit"></h:commandButton>
</h:form>
</h:body>
</html>
response.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Login Response</title>
</h:head>
<h:body>
<h:outputText id="result" escape="false" value="#{LoginBean.authenticate}"/>
</h:body>
</html>
LoginBean.java
public class LoginBean {
private String username;
private String password;
}