gaf*_*fcz 36 jsf redirect managed-bean
有没有办法如何从Java方法将页面重定向到其他页面?
我只能使用以下方式转发它:
FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml");
Run Code Online (Sandbox Code Playgroud)
或使用导航规则faces-config.xml.
你有什么想法?
Bal*_*usC 62
不知道你在追求什么,但ExternalContext#dispatch()它只是一个前进,而不是一个重定向.你想ExternalContext#redirect()改用它.
externalContext.redirect("foo.xhtml");
Run Code Online (Sandbox Code Playgroud)
甚至是外部的(发货时不可能)
externalContext.redirect("http://stackoverflow.com");
Run Code Online (Sandbox Code Playgroud)
你通常喜欢在bean的动作方法中这样做.
由于您在评论中提到了JavaScript,因此以下是使用JS重定向的方法:
window.location = "foo.xhtml";
// Or
window.location = "http://stackoverflow.com";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
84179 次 |
| 最近记录: |