eclipse - eclipse中动态web项目打不开欢迎页

标签 eclipse jsf tomcat facelets welcome-file

我是 eclipse 的初学者,正在尝试一个从 hello world 页面开始的简单 Web 项目。 但是当我在 tomcat 服务器上运行项目时,这个 url 被触发并且我得到 HTTP 404 错误:-

http://localhost:8080/TestWeb/

我的web.xml文件内容如下:-

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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>TestWeb</display-name>
   <welcome-file-list>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
    <welcome-file>HelloWorld.xhtml</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>FacesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>FacesServlet</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> 

最佳答案

您必须检查 HelloWord.xhtml 的位置。正如您在 web.xml 中提到的,如果 HelloWord.xhtml 直接位于 WebContent 下,那么它很好,否则您将看到 Error -404 .

关于eclipse - eclipse中动态web项目打不开欢迎页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29669788/

相关文章:

java - 登录后无法从 OpenAM 获取 uid

eclipse - 在 Eclipse 中更改 doxygen 注释样式

linux - Eclipse 3.8 的 CSS 文件位于哪里?

java - JSF GAE : Value Update Problem in managed bean method

eclipse - Eclipse IDE 是否支持 JSF 2.0?

tomcat - 如何确定 http 400 错误代码 tomcat 的原因?

eclipse - 非常奇怪的 Glassfish 部署失败

Eclipse PDT,PHPUnit 自动完成

jsf - 抽象类和具体类中的依赖注入(inject)

tomcat - Tomcat 5.5 的多个 appbase 目录