0
我有一個部署到wildfly 10服務器的jsf項目。部署後導航到部署根目錄(http://localhost:8080/ {deployment-name} /)獲取「/home/default.xhtml作爲資源在ExternalContext中找不到」錯誤,但當我將文件直接導航到web.xml中定義的文件時hello.xhtml(http://localhost:8080/ {deployment-name} /hello.xhtml)一切正常。 我想它的東西錯了歡迎文件列表 我想知道如何使部署根hello.xhtml? 在此先感謝。 這裏是源文件: web.xml中:welcome-file index.xhtml在ExternalContext中未找到資源
<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app version="3.1" 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_1.xsd"
>
<display-name>Archetype Created Web Application</display-name>
<listener><listener-class>com.sun.faces.config.ConfigureListener</listener-class></listener>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/hello.xhtml</welcome-file>
</welcome-file-list>
</web-app>
和文件結構是:
-main
--java
--resources
--webapp
---hello.xhtml
---WEB-INF
----web.xml
----templates
------default.xhtml
而且hello.xhtml文件是:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
template="/WEB-INF/templates/default.xhtml">
<ui:define name="content">
<f:view>
<h2>This is content</h2>
</f:view>
</ui:define>
</ui:composition>
和/ WEB- INF/templates/default.xhtml是:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:pretty="http://ocpsoft.com/prettyfaces"
>
<h:head>
</h:head>
<h:body>
<div id="container">
<div id="header">
</div>
<div id="content">
<ui:insert name="content"></ui:insert>
</div>
<div id="footer">
</div>
</div>
<div>
</div>
</h:body>
</html>