html <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <head> <title>Login Page</title> </head> <body> <h:form> <h:outputLabel for="username" value="Username:"/> <h:inputText id="username" value="#{loginBean.username}"/> <h:outputLabel for="password" value="Password:"/> <h:inputSecret id="password" value="#{loginBean.password}"/> <h:commandButton value="Login" action="#{loginBean.login}"/> </h:form> </body> </html> import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; @ManagedBean @SessionScoped public class LoginBean { private String username; private String password; public String login() { if (username.equals("admin") && password.equals("password")) { return "success.xhtml"; } else { return "failure.xhtml"; } } // ... }


上一篇:
下一篇:
切换中文