Mud*_*zad 1 jsf redirect managed-bean
我将用户名和密码绑定到支持托管bean.在支持bean中,当我用DB检查用户名和密码时,我想将页面重定向login.xhtml到home.xhtml.我怎样才能做到这一点?
只需返回附加faces-redirect=true参数的视图ID即可.
例如
public String login() {
User found = userService.find(username, password);
if (found != null) {
this.user = found;
return "home?faces-redirect=true"; // Will redirect to home.xhtml.
}
else {
addGlobalErrorMessage("Unknown login, please try again");
return null; // Will stay in current view (and show error message).
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2407 次 |
| 最近记录: |