私はJSFを初めて使用し、JSFでログインスクリプトを作成しようとしています。それはloginsuccessとloginfailureに正常にリダイレクトされます。ユーザーがパスワードを3回間違って入力したときにユーザーをリダイレクトすると、リダイレクトされません - >このエラーが表示されます - > from-view-id '/ indexで一致するナビゲーションケースを見つけることができません。 xhtml 'アクションのために#{login.checkLogin}'と 'loginlocked'という結果を返します。私はNetbeans 7.0を使用しており、faces-config.xmlを見つけることができません。JSFの単純なログイン画面 - 3回の試行のロックアウト
Index.htmlと
<?xml version='1.0' encoding='UTF-8' ?>
<!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://java.sun.com/jsf/html">
<head><title>JSF Login</title></head>
<body>
<h:form>
<table>
<tr>
<td><h:outputText value="Username: " /></td>
<td><h:inputText id="loginname"
value="#{login.userName}" />
</td>
</tr>
<tr>
<td><h:outputText value="Password: " /></td>
<td><h:inputSecret id="password"
value="#{login.password}" />
</td>
</tr>
<tr>
<td> </td>
<td><h:commandButton value="Login"
action="#{login.checkLogin}"/>
</td>
</tr>
</table>
<h:outputLabel value="#{login.label1}" />
</h:form>
</body>
</html>
loginBean.java
package login;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean(name="login")
@RequestScoped
public class loginBean {
private String userName;
private String password;
private String label1;
private static int numOfAttempts = 0;
/** Creates a new instance of loginBean */
public loginBean() {
}
/**
* @return the userName
*/
public String getUserName() {
return userName;
}
/**
* @param userName the userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return the label1
*/
public String getLabel1() {
return label1;
}
/**
* @param label1 the label1 to set
*/
public void setLabel1(String label1) {
this.label1 = label1;
}
public String checkLogin()
{
if (userName.equals("Neetu") && password.equals("123456"))
{
this.setLabel1("Login Success");
return "loginsuccess";
}
else
{
numOfAttempts++;
if (numOfAttempts >= 3)
{
this.setLabel1("Account Locked");
return "loginlocked";
}
else
{
this.setLabel1("Login Failure" + numOfAttempts);
return "loginfailure";
}
}
}
}