Pretty Faces:通用 URL 映射
使用 Pretty Faces 3,我有一些像这样的映射:
<url-mapping id="search">
<pattern value="/search" />
<view-id value="/views/search.xhtml" />
</url-mapping>
<url-mapping id="edit">
<pattern value="/edit" />
<view-id value="/views/edit.xhtml" />
</url-mapping>
有没有办法使用一些通配符来定义所有它们,就像这样?
<url-mapping id="generic">
<pattern value="/*" />
<view-id value="/views/$1.xhtml" />
</url-mapping>
我知道可以在 view-id 值中使用 EL,但我可以管理它来工作。
Using Pretty Faces 3, I have some mappings like these:
<url-mapping id="search">
<pattern value="/search" />
<view-id value="/views/search.xhtml" />
</url-mapping>
<url-mapping id="edit">
<pattern value="/edit" />
<view-id value="/views/edit.xhtml" />
</url-mapping>
Is there any way to define all them using some wildcard, like this?
<url-mapping id="generic">
<pattern value="/*" />
<view-id value="/views/$1.xhtml" />
</url-mapping>
I know is possible to use EL in the view-id value, but I can manage it to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
目前不可能使用这样的通配符。
然而,正如您已经提到的,您可以使用 dynaview (视图 ID 的 EL 表达式)来实现类似的效果。我们最近修复了一个错误,该错误导致此类功能无法正常工作。也许您可以尝试3.3.1-SNAPSHOT。我的猜测是现在它会工作得很好。如果您还有任何其他问题,请随时在论坛上发帖。
Its currently not possible to use a wildcard like this.
However as you already mentioned you could use a dynaview (EL expression for the view-id) to achieve something similar. We recently fixed a bug that prevented something like this to work correcty. Perhaps you could give 3.3.1-SNAPSHOT a try. My guess is that it will work fine now. Feel free to post a message on the forums if you have any further problems.
您可能最好使用 Rewrite 它可以让您进行更强大的配置:
https://github.com/ocpsoft/socialpm/blob/master/web/src/main/java/com/ocpsoft/socialpm/URLRewriteConfiguration.java
You might be better off using Rewrite which lets you do more powerful configuration:
https://github.com/ocpsoft/socialpm/blob/master/web/src/main/java/com/ocpsoft/socialpm/URLRewriteConfiguration.java