我正在使用 jee7 开发一个 Web 应用程序,我会将我的 .xhtml 文件组织到不同的文件夹中。我尝试设置 web.xml 和 faces-config.xml 文件,但是当我单击按钮进入文件夹时,我遇到了这个问题,
com.sun.faces.context.FacesFileNotFoundException: /protected-area/index.xhtml Not Found in ExternalContext as a Resource
当我想进入两个文件夹“保护区”和“公共”时出现问题。我希望我很清楚,我不明白,因为它不起作用。非常感谢您的帮助。
这些是我的文件。
索引.xhtml
<h:head>
<title>jingsen</title>
</h:head>
<h:body>
Select where you want to go:
<h:form>
<h:commandButton value="protected area" action="protected-area"></h:commandButton>
<h:commandButton value="public" action="public"></h:commandButton>
<h:commandButton value="testtest" action="test"></h:commandButton>
</h:form>
</h:body>
web.xml
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</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>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>jingsen-realm</realm-name>
<form-login-config>
<form-login-page>/login.xhtml</form-login-page>
<form-error-page>/error.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<display-name>Admin Pages</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<description/>
<url-pattern>/protected-area/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>admin</role-name>
<role-name>cassa</role-name>
<role-name>cameriere</role-name>
<role-name>cucina</role-name>
<role-name>bar</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>admin</role-name>
</security-role>
<security-role>
<role-name>cameriere</role-name>
</security-role>
<security-role>
<role-name>cucina</role-name>
</security-role>
<security-role>
<role-name>bar</role-name>
</security-role>
面孔-config.xml
<navigation-rule>
<from-view-id>index.xhtml</from-view-id>
<navigation-case>
<from-outcome>protected-area</from-outcome>
<to-view-id>/protected-area/index.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>public</from-outcome>
<to-view-id>/public/index.xhtml</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>test</from-outcome>
<to-view-id>prova.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>