我目前无法从浏览器 URL 公开我的 JSF 文件。我的项目结构是这样的:
<PROJECT_NAME>
--->WebContent
--->index.xhtml
--->subfolder1
--->subjsf.xhtml
--->subfolder2
--->subjsf.xhtml
--->subfolder3
--->subjsf.xhtml
这是我的 web.xml:
<?xml version="1.0"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>PROJECT_NAME</display-name>
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>blueSky</param-value>
</context-param>
<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>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/pages/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
我的面孔配置:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>subfolder1</from-outcome>
<to-view-id>/subfolder1/subjsf.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<application>
<resource-bundle>
<base-name>resources</base-name>
<var>msgs</var>
</resource-bundle>
</application>
</faces-config>
不使用重定向,它似乎工作正常。但是启用重定向会出现此错误:
com.sun.faces.context.FacesFileNotFoundException: /subjsf.xhtml Not Found in ExternalContext as a Resource
当您直接访问 URL 时,如下所示:<hostname>:<port>/PROJECT_NAME/subfolder1/subjsf.xhtml it also gave the same error above.
我想启用 URL 的重定向以刷新并显示当前页面名称。另外,有没有办法对子文件夹使用隐式导航?
真的很感谢你们的帮助!先感谢您...