注意:路徑配置,好比 /xxx/user 配置爲 /xxx/user/ ,可能引起 shiro 控制出錯.引起其餘一些未知的BUG.這個東西...仍是有不少BUG的.通常狀況,最後不要以"/"結束. html
PrettyFaces是一個JSF1.2和JSF2.0的擴展,是一個開源基於過濾器(Filter)的Servlets擴展.用來建立便於書籤收藏、漂亮的網址。 PrettyFaces優雅的解決了這個問題,包括諸如功能:網頁裝載行動,無縫的跟faces的導航整合,動態視圖的ID分配和管理參數分析,無需配 置,兼容其餘JSF框架。PrettyFaces優雅地解決了「RESTful URL」 問題,包括這樣一些特性如: express
You may either use Maven (recommended) to include PrettyFaces in your project, or you can download the distribution ZIP file directly. app
If you are upgrading from PrettyFaces 3.x, note that all functionality is backwards compatible, but you may wish to review the migration guide to learn about new features made available in the latest releases. 框架
POM.XML jsp
<!-- for JSF 2.x --> <dependency> <groupId>org.ocpsoft.rewrite</groupId> <artifactId>rewrite-servlet</artifactId> <version>2.0.12.Final</version> </dependency> <dependency> <groupId>org.ocpsoft.rewrite</groupId> <artifactId>rewrite-config-prettyfaces</artifactId> <version>2.0.12.Final</version> </dependency>
This is where you will create URL mappings between external URL patterns and your internal view files, Servlets, and other resources. Be sure to replace the mapping below with a mapping that matches your application. ide
/WEB-INF/pretty-config.xml ui
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd"> <url-mapping id="login"> <pattern value="/login" /> <view-id value="/legacy/user/login.jsp" /> </url-mapping> </pretty-config>
This part is all up to you! You’ll need to figure out which URLs in your application you want to 「prettify」 – so check out the documentation for details on how to fully utilize the PrettyFaces URL-mapping system. url
Additionally, be sure to check out the Rewrite examples or reference manual to learn more about Rewrite, and the powerful options it offers beyond the PrettyFaces configuration module. spa
<url-mapping id="view-user"> <pattern value="/user/#{username}" /> <view-id value="/user/view.xhtml" /> </url-mapping> <!-- Maps "/user/#{username}" to the URL "/user/view.xhtml?username=value" -->