【发布时间】:2013-09-28 00:21:21
【问题描述】:
我是 Java 和 JSF 的新手。我正在使用 eclipse Indigo 和 Tomcat 6.0.3 和 JSF 2.0。我正在使用 Maven 并将战争部署到服务器。
我在 Eclipse 中配置了服务器,我通常在 localhost:8080 中获取 apache 页面。
但是当我尝试像 localhost:8080/ContactFormJSF/ 这样访问我的页面时,我得到的消息是
HTTP Status 404 - /ContactFormJSF/
type Status report
message /ContactFormJSF/
description The requested resource (/ContactFormJSF/) is not avilable.
这类似于 Adduser.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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>JSF 2.0 Hello World</title>
</h:head>
<h:body>
<h3>JSF 2.0 Hello World Example - hello.xhtml</h3>
</h:body>
</html>
我什至在Web.xml中配置了“servlet-mapping”、“welcome-file-list”
我的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee">
<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>
<welcome-file-list>
<welcome-file>AddUser.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<session-config>
<session-timeout>15</session-timeout>
</session-config>
</web-app>
【问题讨论】:
-
我已经在上面添加了我的 web.xml,并且罐子在 lib 文件夹中,并且 iam 使用的 url 是 localhost:8080/ContactFormJSF/
-
看看:balusc.blogspot.ro/2011/01/…。这应该对您有所帮助。
-
@Khirthan..您的
web.xml配置似乎是正确的。您缺少jar的某些部分。确保WEB-INF/lib下需要的jar -
@kark 我有 jsf 的所有 jar,即 jsf-impl.jar、jsf-api.jar、jstl.jar、commons-beanutils-1.7.0.jar、commons-chain-1.1。罐子,commons-collections.jar,commons-logging-1.0.4.jar,commons-digester-1.8.jar。我应该添加除此之外的任何其他内容吗??
-
我不是手动部署 jars,我只是在服务器中部署 Final War 输出。我的 pom.xml 有很多包含插件、存储库、依赖项的内容。