jsf返回到欢迎页面,而不是上一页

jsf返回到欢迎页面,而不是上一页,jsf,primefaces,jsf-2,Jsf,Primefaces,Jsf 2,我有3个jsf页面: 欢迎页面:index.xhtml 第二页:displayall.xhtml,包含指向第三页的commandlink:login_jsf.xhtml 问题是,当我按下navigator return按钮时,它会重定向到欢迎页面,而不是displayall.xhtml 以下是我用于重定向的标记: <p:commandLink id="login" action="login_jsf?faces-redirect=true" style="margin-right:2

我有3个jsf页面: 欢迎页面:index.xhtml 第二页:displayall.xhtml,包含指向第三页的commandlink:login_jsf.xhtml

问题是,当我按下navigator return按钮时,它会重定向到欢迎页面,而不是displayall.xhtml

以下是我用于重定向的标记:

   <p:commandLink id="login" action="login_jsf?faces-redirect=true" style="margin-right:20px">
                <h:outputText value="Se connecter" />
            </p:commandLink>
my web.xml

    <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>exemple_jpa</display-name>
  <welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
  </welcome-file-list>
  <context-param>
    <param-name>com.sun.faces.numberOfViewsInSession</param-name>
    <param-value>5</param-value>
  </context-param>
  <context-param>
    <param-name>com.sun.faces.serializeServerState</param-name>
    <param-value>false</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
    <param-value>true</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>


</web-app>

将导航规则添加到faces-config.xml请注意重定向标记:

<navigation-rule>
    <from-view-id>displayall.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>login</from-outcome>
        <to-view-id>login.xhtml</to-view-id>
        <redirect />
    </navigation-case>
</navigation-rule>
然后:

<p:commandLink id="login" action="#{navigationHandler.moveToLoginPage}"> 
          <h:outputText value="Se connecter" />
</p:commandLink>

谢谢!添加重定向标记对我来说很有用,使用login?faces redirect=true而不使用_jsf怎么样。另见
<p:commandLink id="login" action="#{navigationHandler.moveToLoginPage}"> 
          <h:outputText value="Se connecter" />
</p:commandLink>