【问题标题】:Can I use wildcard character * in JSF navigation rule?我可以在 JSF 导航规则中使用通配符 * 吗?
【发布时间】:2016-05-24 04:39:09
【问题描述】:

在 JSF 页面导航中有什么方法可以创建百搭规则吗?我的模板标题中有一个注销链接(几乎适用于所有页面)。我只想给出一条规则,将安全文件夹中的所有页面导航到根目录中的索引页面。

<navigation-rule>
    <from-view-id>/secure/*.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>index</from-outcome>
        <to-view-id>/index.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

我试过了,但是解析器说它没有找到从/secure/pagex.xhtml/index.xhtml 的规则。这是真的?我必须为我的所有页面一个一个地给出一个规则?

【问题讨论】:

    标签: jsf navigation wildcard


    【解决方案1】:

    通配符只能作为后缀(作为最后一个字符)。

    <navigation-rule>
        <from-view-id>/secure/*</from-view-id>
        <navigation-case>
            <from-outcome>index</from-outcome>
            <to-view-id>/index.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
    

    &lt;from-view-id&gt; 是可选的。您也可以直接删除它。

    <navigation-rule>
        <navigation-case>
            <from-outcome>index</from-outcome>
            <to-view-id>/index.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
    

    或者,更好的是,使用隐式导航,然后您可以完全删除 &lt;navigation-rule&gt;

    例如获取

    <h:button ... outcome="/index" />
    <h:link ... outcome="/index" />
    

    或发布

    public String logout() {
        // ...
    
        return "/index?faces-redirect=true";
    }
    

    JSF 会自动担心扩展和映射。

    另见:

    【讨论】:

      猜你喜欢
      • 2013-10-22
      • 1970-01-01
      • 2014-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-26
      • 1970-01-01
      相关资源
      最近更新 更多