gpt4 book ai didi

eclipse - 我使用 Tomcat 和 Eclipse 编写的第一个 JSF 程序出错

转载 作者:行者123 更新时间:2023-11-28 23:01:12 26 4
gpt4 key购买 nike

我是 Java 和 JSF 的新手。我正在使用 eclipse Indigo 和 Tomcat 6.0.3 以及 JSF 2.0。我正在使用 Maven 并将 war 部署到服务器。

我在 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>

最佳答案

检查以下条件

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

关于eclipse - 我使用 Tomcat 和 Eclipse 编写的第一个 JSF 程序出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18953583/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com