【问题标题】:Error in my First JSF Program with Tomcat and Eclipse我的第一个使用 Tomcat 和 Eclipse 的 JSF 程序出错
【发布时间】: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 有很多包含插件、存储库、依赖项的内容。

标签: eclipse jsf maven tomcat


【解决方案1】:

检查以下条件

  1. 检查WEB-INF/lib目录下插入的所需jar(强烈推荐)
  2. 检查servlet 是否已映射到Web.xml
  3. 检查您在浏览器中调用正确的URL 模式

【讨论】:

    猜你喜欢
    • 2012-04-26
    • 1970-01-01
    • 2011-01-04
    • 2015-12-10
    • 2011-04-02
    • 1970-01-01
    • 1970-01-01
    • 2011-08-18
    • 1970-01-01
    相关资源
    最近更新 更多