注意:路径配置,比如 /xxx/user 配置为 /xxx/user/ ,可能引发 shiro 控制出错.引发其他一些未知的BUG.这个东西...还是有很多BUG的.一般情况,最后不要以"/"结束.
PrettyFaces是一个JSF1.2和JSF2.0的扩展,是一个开源基于过滤器(Filter)的Servlets扩展.用来创建便于书签收藏、漂亮的网址。 PrettyFaces优雅的解决了这个问题,包括诸如功能:网页装载行动,无缝的跟faces的导航整合,动态视图的ID分配和管理参数分析,无需配 置,兼容其他JSF框架。PrettyFaces优雅地解决了“RESTful URL” 问题,包括这样一些特性如:
You may either use Maven (recommended) to include PrettyFaces in your project, or you can download the distribution ZIP file directly.
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
<!-- 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.
/WEB-INF/pretty-config.xml
<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.
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.
<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" -->