gpt4 book ai didi

seam - 如何在 pages.xml 中指定重写模式

转载 作者:行者123 更新时间:2023-12-04 17:28:00 26 4
gpt4 key购买 nike

我在几个文件夹中有很多 xhtml 文件。我想将网址重写为

来自 http://localhost:8080/folder1/file1.seamhttp://localhost:8080/folder1/file1

在 file1.page.xml 我给了

<rewrite pattern="/folder1/file1" />

以上为我提供了正确的模式。但是我有很多文件,我不想在每个 page.xml 文件中指定这种重写模式。有没有办法在 pages.xml 中指定它?

编辑:
http://localhost:8080/folder2/file2.seam to http://localhost:8080/folder2/file2
http://localhost:8080/folder3/file3.seam to http://localhost:8080/folder3/file3

我的翻译的更多样本

最佳答案

  • 重写基于重写发生
    在 pages.xml 中找到的 View 模式
  • Seam URL 重写同时传入
    和传出 URL 重写基于
    同款

  • 例子:
    <page view-id="/home.xhtml">
    <rewrite pattern="/home" />
    </page>
  • 任何对/home 的传入请求都将发送到 /home.xhtml
  • 生成的任何通常指向 /home.seam 的链接将改为重写为 /home
  • 重写模式仅匹配查询参数之前的 URL 部分
  • 这两个都将匹配
  • /home.seam?conversationId=13
  • /home.seam?color=red

  • 重写规则可以将这些查询参数带入
    考虑
    <page view-id="/home.xhtml">
    <rewrite pattern="/home/{color}" />
    <rewrite pattern="/home" />
    </page>
    /home/red 的传入请求将被视为请求 /home.seam?color=red
    如果颜色是页面参数,则传出 URLr /home.seam?color=blue将输出为 /home/blue
    记住:
  • 规则按顺序处理
  • 在更一般的规则之前列出更具体的规则

  • 如果你想隐藏对话 id,你可以这样做:
    <page view-id="/search.xhtml">
    <rewrite pattern="/search-{conversationId}" />
    <rewrite pattern="/search" />
    </page>

    现在 /search.seam?conversationId=16将写为 /search-16
    如果要匹配多个页面,请使用通配符
    <page login-required="true" view-id="/admin/*">

    希望这可以帮助

    更新

    回答您的更新问题。

    您可以使用外部重写创建通配符重写,但不能使用 Seam 的 URL 重写。使用基于 View 的重写,您需要为每个 View ID 声明一个模式,就像您描述自己的那样。
    对不起,但这就是 cookies 碎的方式。 :-)

    关于seam - 如何在 pages.xml 中指定重写模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4624089/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com