我是Maven的新手。我正在嘗試使用maven和eclipse kepler構建一個web項目。但在我運行Maven構建乾淨安裝.xhtml文件不是WEB-INF文件夾,這最終讓資源未找到錯誤maven build後無法運行web項目
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>CassandraPrimefacesKunderaIntegration</display-name>
<welcome-file-list>
<welcome-file>home.xhtml</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>*.xhtml</url-pattern>
</servlet-mapping>
<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>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
內
的pom.xml不依賴
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>CassandraPrimefacesKunderaIntegration</groupId>
<artifactId>CassandraPrimefacesKunderaIntegration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>CassandraPrimefacesKunderaIntegration</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
當我調用的Maven用乾淨的建設安裝目標文件夾是像下面
展開組件 - >
src/main/java -->WEB-INF/classes
src/main/resources -->WEB-INF/classes
src/main/webapp -->WEB-INF/classes
現在,當我從Tomcat運行工程[右鍵 - >運行 - >在服務器上運行]它顯示資源不可用錯誤
你看過「pages」文件夾嗎? – Stefan
是的,網頁在頁面文件夾內 當我試圖直接運行home.xhtml的url是 http:// localhost:9091/CassandraPrimefacesKunderaIntegration/faces/WEB-INF/classes/pages/home.xhtml 它給的資源找不到錯誤 我檢查了目標文件夾的頁面文件夾是在WEB-INF之外。 我錯過了什麼,如果是這樣,請指導。 謝謝 – Supriti