Pretty Faces: Generic URL mapping

旧时模样 提交于 2019-12-10 17:03:33

问题


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.


回答1:


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.




回答2:


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"))


来源:https://stackoverflow.com/questions/7026232/pretty-faces-generic-url-mapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!