尝试请求JSF页面时获取404状态

时间:2013-11-03 14:06:28

标签: java eclipse tomcat jsf-2 http-status-code-404

我在运行我的eclipse jsf测试项目时遇到了困难。我使用的是eclipse kepler,apache tomcat 7.0和JSF 2.1.9。 每当我尝试请求我的helloWorld.xhtml(url /localhost/helloWorldJSF/helloWorld.xhtml)时,它会将我带到404状态,说明所请求的资源不可用,但我不明白为什么。

这是我的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" 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>HelloJSF</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</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>

我的helloWorldJSF.xhtml:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.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>Hello JSF</title>
</h:head>
<h:body>
    <h:form id="helloForm">
        <h:outputText value="Hello JSF"></h:outputText>
    </h:form>
</h:body>

我做错了什么?我在设置中设置了相应的库(JSF 2.1.9)。 faces-config.xml也指2.1版。

提前致谢!

1 个答案:

答案 0 :(得分:1)

我通过删除服务器并添加新的服务器配置解决了这个问题。

相关问题