简体   繁体   中英

Pretty Faces: Generic URL mapping

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.

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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