我在几个文件夹中有很多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
我翻译的更多样本
答案 0 :(得分:8)
根据重写进行重写 在pages.xml中为视图找到的模式
Seam URL重写同时进行传入 和基于的传出URL重写 相同的模式
示例:
<page view-id="/home.xhtml">
<rewrite pattern="/home" />
</page>
/home.xhtml
/home.seam
的链接都会被重写为/home
重写模式仅匹配查询参数
这两个都将匹配
/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
将输出为
/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重写。使用基于视图的重写,您需要为每个视图ID声明一个模式,就像您描述自己一样。 对不起,但这就是cookie崩溃的方式。 : - )
答案 1 :(得分:2)