【问题标题】:JSF2 Unable to find matching navigation case with from-view-id with outcome 'Logout' [duplicate]JSF2无法找到匹配的导航案例与来自视图ID的结果“注销”[重复]
【发布时间】:2014-07-05 05:44:55
【问题描述】:

我正在使用下面的代码进行注销

public String logout() throws ServletException {
        cleanSession();
        FacesContext.getCurrentInstance().getExternalContext()
                .invalidateSession();
        HttpServletRequest request = (HttpServletRequest) FacesContext
                .getCurrentInstance().getExternalContext().getRequest();
        FacesContext.getCurrentInstance().getExternalContext()
                .invalidateSession();


            return "Logout";

    }

Logout.xhtml 页面位于 login 文件夹中,但我最终得到了

无法找到与 from-view-id 匹配的导航案例 '/core/dashboard.xhtml' 用于操作 '#{loginBean.logout}' 的结果 '退出'

我尝试了 Stackoverflow 中提供的最大解决方案,但无法获得解决方案..我也尝试了以下代码

public String logout() throws ServletException {
        cleanSession();
        FacesContext.getCurrentInstance().getExternalContext()
                .invalidateSession();
        HttpServletRequest request = (HttpServletRequest) FacesContext
                .getCurrentInstance().getExternalContext().getRequest();
        FacesContext.getCurrentInstance().getExternalContext()
                .invalidateSession();

        try {
            String action = request.getContextPath()
                    + "/login/Logout.xhtml";
            return action;
        } catch (Exception e) {
            LOG.error("Exception in forwarding at Logout", e);
        }
        return null;
    }

但同样的问题..谁能告诉我是什么问题?

我稍作改动并添加了这个

<p:commandLink ajax="false" rendered="#{loginBean.loginStatus}"
                    value="Logout" actionListener="#{loginBean.logout}" action="Logout">

                </p:commandLink>

以前是这样的

<p:commandLink ajax="false" rendered="#{loginBean.loginStatus}"
                    value="Logout" action="#{loginBean.logout}"
                     >
                </p:commandLink>

【问题讨论】:

    标签: jsf jsf-2


    【解决方案1】:

    您正在尝试从 /core/ 导航到另一个目录 /login/

    JSF 隐式导航允许您导航到同一文件夹或任何父文件夹中的页面。

    此类场景请使用 faces-config.xml 导航规则。

    【讨论】:

    • 请分享你的文件夹结构,h:commandButton tag sn-p.
    • 同样的问题即将出现Unable to find matching navigation case with from-view-id '/core/dashboard.xhtml' for action 'Logout' with outcome 'Logout'
    • 在问题部分添加
    • 你能从 faces-config.xml 分享你的 配置吗?
    • 我使用的是 JSF2,所以不需要在 faces.config.xml 文件中编写导航规则
    猜你喜欢
    • 1970-01-01
    • 2014-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多