Redirect 不';t重定向JavaFaces 2.0 Primefaces p:commandButton o p:commandLink
我有一些重定向问题。Im使用primefaces和JSF2.1。问题是,JSF2.1没有导航规则,在搜索我发现的答案时,我可以将“faces redirect=true”。问题是这不起作用,我不知道为什么。浏览器不断地告诉我“No se puede encentral el caso de navegación concurrence del ID de vista'/Autenticacion/login.xhtml'para la acción{1}'con el resultado'{2}'”,就像我没有一个导航框来为第一个操作和第二个结果“/Autenticacion/login.xhtml”导航一样。JSF2.1没有创建faces-config.xml文件,我创建了它,并为该操作添加了规则,但问题仍然存在 这些是我的文件: 登录BEANRedirect 不';t重定向JavaFaces 2.0 Primefaces p:commandButton o p:commandLink,redirect,jsf-2,primefaces,faces-config,Redirect,Jsf 2,Primefaces,Faces Config,我有一些重定向问题。Im使用primefaces和JSF2.1。问题是,JSF2.1没有导航规则,在搜索我发现的答案时,我可以将“faces redirect=true”。问题是这不起作用,我不知道为什么。浏览器不断地告诉我“No se puede encentral el caso de navegación concurrence del ID de vista'/Autenticacion/login.xhtml'para la acción{1}'con el resultado'{2}
@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>
/Autenticacion/login.xhtml
#{controlLogin.logIn}
指数
/index.xhtml
所以如果有人能帮我做这个重定向…谢谢 事实上,在jsf2.x中,您不必定义导航规则。您根本不需要
faces config.xml
,只需要在一些没有注释的特殊情况下(例如自定义ExceptionHandlerFactory
)
使用return“index?faces redirect=true”
完全可以faces redirect=true
表示您将从一个xhtml重定向到另一个xhtml,而不是默认值转发
在这种情况下,只需确保您的index.xhtml
页面与您尝试访问它的页面位于同一目录中
否则,如果索引
页面位于另一个目录中,则必须使用正斜杠/
指定绝对路径,如下所示:“/indexFolder/index?faces redirect=true”
事实上,在jsf2.x中,您不必定义导航规则。您根本不需要faces config.xml
,只需要在一些没有注释的特殊情况下(例如自定义ExceptionHandlerFactory
)
使用return“index?faces redirect=true”
完全可以faces redirect=true
表示您将从一个xhtml重定向到另一个xhtml,而不是默认值转发
在这种情况下,只需确保您的index.xhtml
页面与您尝试访问它的页面位于同一目录中
否则,如果索引
页面位于另一个目录中,则必须使用正斜杠/
指定绝对路径,如下所示:“/indexFolder/index?faces redirect=true”
尝试使用FacesContext.getCurrentInstance().getExternalContext().redirect(yourURL);尝试使用FacesContext.getCurrentInstance().getExternalContext().redirect(yourURL);谢谢你的回答。为了记录在案,就像我在使用java faces一样,我必须将“/faces”添加到文件夹路径中,这是我的页面。谢谢!只是猜测而已。您可能已经在web.xml
中定义了facesservlet/Faces/*
。如果您更改(或添加新的)url模式
为*.jsf(或*.xhtml)
,它将不会在文件夹路径中添加“/faces”。谢谢您的回答。为了记录在案,就像我在使用java faces一样,我必须将“/faces”添加到文件夹路径中,这是我的页面。谢谢!只是猜测而已。您可能已经在web.xml
中定义了facesservlet/Faces/*
。如果更改(或添加新的)url模式
为*.jsf(或*.xhtml)
,它将在不向文件夹路径添加“/faces”的情况下工作。