我是 JSF 的新手,不知道发生了什么。
我不断收到此错误:/index.xhtml @12,80 value="#{LoginBean.username}": Target Unreachable, identifier 'LoginBean' resolve to null
我已将问题归结为...
索引.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>
响应.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>
登录Bean.java
public class LoginBean {
private String username;
private String password;
}