OmniFaces FacesView 的无扩展 URL 在 1.12 中不起作用
Extensionless URLs with OmniFaces FacesView does not work in 1.12
我已经成功地使用了漂亮的 omnifaces-lib (1.12) 及其一些实用程序功能。现在我想尝试它的 faceviews-feature for extensionless urls。看完
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 results in "requested resource is not available" while http://localhost:8080/TestApp/test.jsf 按预期工作。我还尝试了
中的示例
http://omnifaces.org/docs/javadoc/2.2/org/omnifaces/facesviews/package-summary.html
有任何(配置)问题吗?感谢您的任何建议。
我正在使用 mojarra 2.2.8 和 omnifaces 1.12 和 tomcat8。我没有任何其他 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>
那是我的错误。 /META-INF/services/javax.servlet.ServletContainerInitializer
文件在 1.10 拆分期间消失了。该文件包含一条指令,让容器在启动期间执行 org.omnifaces.facesviews.FacesViewsInitializer
class,进而负责扫描和注册无扩展名文件。它在所有 2.x 版本中工作正常,最后一个 1.x 版本是 1.8.3.
它已被添加回 Maven 中的 this commit and a new 1.12.1 release has been baked. It's available here。
我已经成功地使用了漂亮的 omnifaces-lib (1.12) 及其一些实用程序功能。现在我想尝试它的 faceviews-feature for extensionless urls。看完
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 results in "requested resource is not available" while http://localhost:8080/TestApp/test.jsf 按预期工作。我还尝试了
中的示例http://omnifaces.org/docs/javadoc/2.2/org/omnifaces/facesviews/package-summary.html
有任何(配置)问题吗?感谢您的任何建议。
我正在使用 mojarra 2.2.8 和 omnifaces 1.12 和 tomcat8。我没有任何其他 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>
那是我的错误。 /META-INF/services/javax.servlet.ServletContainerInitializer
文件在 1.10 拆分期间消失了。该文件包含一条指令,让容器在启动期间执行 org.omnifaces.facesviews.FacesViewsInitializer
class,进而负责扫描和注册无扩展名文件。它在所有 2.x 版本中工作正常,最后一个 1.x 版本是 1.8.3.
它已被添加回 Maven 中的 this commit and a new 1.12.1 release has been baked. It's available here。