使用OmniFaces FacesView的无扩展URL在1.12中不起作用

时间:2015-11-26 09:10:57

标签: jsf url-rewriting web.xml tomcat8 omnifaces

我已经成功使用了很好的omnifaces-lib(1.12)及其一些util-functions。现在我想为无扩展网址尝试其facesviews-feature。读完后

http://showcase.omnifaces.org/facesviews/ExtensionlessURLs

并添加魔术线

<context-param>
  <param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
  <param-value>/*.xhtml</param-value>
</context-param>

到web.xml,它似乎没有任何影响。服务器控制台也没有说明新配置。

调用http://localhost:8080/TestApp/test会导致“请求的资源不可用”,而http://localhost:8080/TestApp/test.jsf按预期工作。我也试过

中的例子

http://omnifaces.org/docs/javadoc/2.2/org/omnifaces/facesviews/package-summary.html

有没有(配置)-issue?谢谢你的任何建议。

我正在使用mojarra 2.2.8和omnifaces 1.12和tomcat 8.我没有任何其他jsf-libs,例如primefaces或prettyfaces。

的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>Test</display-name>
<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
     <url-pattern>/javax.faces.resource/*</url-pattern>
     <url-pattern>*.jsf</url-pattern>
     <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
    <!-- param-value>Production</param-value -->
</context-param>
<context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
</context-param>
<context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.FACELETS_DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
    <param-value>/*.xhtml</param-value>
</context-param>
<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>


</web-app>

1 个答案:

答案 0 :(得分:1)

那是我的错。 {1.1}分割期间/META-INF/services/javax.servlet.ServletContainerInitializer文件消失了。该文件包含一条指令,让容器在启动期间执行org.omnifaces.facesviews.FacesViewsInitializer类,而后者又负责扫描和注册无扩展文件。它适用于所有2.x版本,最后的1.x版本工作在1.8.3。

它已被添加回this commit,并且已经发布了新的1.12.1版本。它在Maven中可用here