加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 05:35:08 所属栏目:百科 来源:网络整理
导读:我在几个文件夹中有很多xhtml文件.我想重写网址为 从http://localhost:8080/folder1/file1.seam到http://localhost:8080/folder1/file1 在file1.page.xml中我给了 rewrite pattern="/folder1/file1" / 以上为我提供了正确的模式.但我有很多文件,我不想在每个
我在几个文件夹中有很多xhtml文件.我想重写网址为

从http://localhost:8080/folder1/file1.seam到http://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中为视图找到的模式
> 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

如果color是页面参数,则传出的URLr /home.seam?color=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重写.使用基于视图的重写,您需要为每个视图ID声明一个模式,就像您描述自己一样.对不起,但这就是cookie崩溃的方式.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读