我有Login.xhtml
和Home.xhtml
。我在web.xml
配置URL模式如下自定義FacesServlet的<url-pattern>擺脫.xhtml擴展
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>Login.xhtml</welcome-file>
</welcome-file-list>
當我運行整個項目,在登錄頁面URL
是這樣http://localhost:8080/fran/Login.xhtml
,這裏fran
是我的項目名稱..
不過,我想它http://localhost:8080/fran/Login/
而不是http://localhost:8080/fran/Login.xhtml
。
我怎樣才能做到這一點?是否可以爲每個頁面定製<url-pattern>
以擺脫.xhtml
擴展?
解決
由於BalusC在評論下面提到... OmniFaces FacesViews是真棒。以下是我所做的步驟:
- 將
omnifaces-1.5.jar
放置在/WEB-INF/lib
文件夾中。 添加以下代碼
web.xml
:<context-param> <param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name> <param-value>/*.xhtml</param-value> </context-param>
這就是它的配置。它工作得很好。
看看http://ocpsoft.org/prettyfaces/,看看* 2。在主頁面 – Daniel
@Daniel ..中創建pretty-config.xml *示例http://ocpsoft.org/prettyfaces是一個不錯的選擇。在'pretty faces'中,需要在' web.xml' – kark
[OmniFaces FacesViews](http://showcase.omnifaces.org/facesviews/ExtensionlessURLs)提供了一種零配置的方式來擺脫'.xhtml'擴展名。它已被用於https://showcase.omnifaces.org和https://zeef.com。 – BalusC