我在重定向方面遇到了一些问题。我正在使用 primefaces 和 JSF 2.1。问题是 JSF 2.1 没有导航规则并且搜索我发现我可以输入“faces-redirect=true”的答案。问题是那不起作用,我不知道为什么。浏览器一直告诉我“No se puede encontrar el caso de navegación 巧合 del ID de vista '/Autenticacion/login.xhtml' para la acción {1}' con el resultado '{2}'” 就像我没有导航“/Autenticacion/login.xhtml”的情况下,第一个动作和第二个结果。使用 JSF 2.1 不会创建 faces-config.xml 文件,我创建了它并添加了该操作的规则,但问题仍然存在。
这些是我的文件:
登录豆
@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 命令按钮
<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>
因此,如果有人可以帮助我进行此重定向...谢谢!