データベースからユーザー名とパスワードをチェックするログインページを作成しようとしています。送信ボタンをクリックするとすぐに、ウェルカムページではなくwelcome.xhtmlファイルのコードが表示されます。誰かがこの問題を解決する方法を教えてもらえますか?
フェイスレットを使用するようにlogin.xhtmlに変更を加えた後も、同じ問題が発生します。
login.xhtml:
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<h:form>
<p>
<h:inputText
id="username"
title="Username"
value="#{userBean.username}">
<h:inputText
id="password"
title="Password"
value="#{userBean.password}">
</h:inputText>
<h:commandButton id="submit" value="Submit" action="#{userBean.validate}"/>
</p>
</h:form>
</h:body>
マネージドBean:
@Stateless
public class userBean implements Serializable {
private String username, password;
private String response = "";
private UserFacade userFacade;
public userBean() {
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserName() {
return username;
}
public void setUserName(String username) {
this.username = username;
}
public String validate(){
System.out.println("in bean");
response = userFacade.validateUser(username, password);
if (response.equals("MATCH"))
return "welcome.xhtml";
else
return "login.xhtml";
}
}