简体   繁体   English

Pretty Faces:通用 URL 映射

[英]Pretty Faces: Generic URL mapping

Using Pretty Faces 3, I have some mappings like these:使用 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> 

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.我知道可以在 view-id 值中使用 EL,但我可以管理它来工作。

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.但是,正如您已经提到的,您可以使用 dynaview(视图 ID 的 EL 表达式)来实现类似的效果。 We recently fixed a bug that prevented something like this to work correcty.我们最近修复了一个错误,该错误会阻止这样的事情正常工作。 Perhaps you could give 3.3.1-SNAPSHOT a try .也许你可以试试 3.3.1-SNAPSHOT My guess is that it will work fine now.我的猜测是它现在可以正常工作了。 Feel free to post a message on the forums if you have any further problems.如果您有任何进一步的问题,请随时在论坛上发布消息。

You might be better off using Rewrite which lets you do more powerful configuration:使用Rewrite可能会更好,它可以让您进行更强大的配置:

https://github.com/ocpsoft/socialpm/blob/master/web/src/main/java/com/ocpsoft/socialpm/URLRewriteConfiguration.java https://github.com/ocpsoft/socialpm/blob/master/web/src/main/java/com/ocpsoft/socialpm/URLRewriteConfiguration.java

 .addRule(Join.path("/{page}").to("/views/{page}.xhtml"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM