Im有一些重定向問題。我使用primefaces和JSF 2.1。事情是,JSF 2.1沒有導航規則,並尋找答案,我發現我可以把「faces-redirect = true」。問題是,這沒有奏效,我不知道爲什麼。瀏覽器總是告訴我:「我沒有導航的東西,就像我沒有導航一樣」用「/Autenticacion/login.xhtml」作爲第二個結果的第一個操作。使用JSF 2.1不會創建一個faces-config.xml文件,我創建它並添加了該操作的規則,但問題仍然存在。不重定向JavaFaces 2.0 Primefaces p:commandButton o p:commandLink
這些都是我的文件:
LOGIN BEAN
@ManagedBean(name="controlLogin")
@SessionScoped
public class ControladorLogin implements Serializable{
public String logIn(){
//actions
return "index" //algo tryed index.xhtml or index?faces-redirect=true
}
PRIMEFACES COMMANDBUTTON
<p:commandButton action="#{controlLogin.logIn}" value="Loguearse" ajax="false"/>
我也嘗試用commandLink
<p:commandLink action="#{controlLogin.logIn}" value="Loguearse" ajax="false"/>
faces-config.xml中/ /如果不是必須的我可以刪除它
<navigation-rule>
<from-view-id>/Autenticacion/login.xhtml</from-view-id>
<navigation-case>
<from-action>#{controlLogin.logIn}</from-action>
<from-outcome>index</from-outcome>
<to-view-id>/index.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
所以,如果任何人都可以幫助我做這個重定向...謝謝!
嘗試使用FacesContext.getCurrentInstance()。getExternalContext()。redirect(yourURL); – rags