2014-05-20 72 views
0

我的項目在Apache Tomcat 6服務器上運行時會得到404。 localhost8080正常工作,因爲我得到的Tomcat主頁。我的xhtml文件位於我的webcontent文件夾中,並且我相信我的web.xml已正確設置。eclipse動態web項目jsf http 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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> 
    <display-name>Xperiment</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>/faces/*</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> 

實驗

<!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:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core"> 

<h:outputLabel value="Ontology #{ontologyBean.name}"></h:outputLabel> 
     <h:form> 
      <h:panelGrid columns = "2"> 
       <h:outputText value="Experiment ID"></h:outputText> 
       <h:outputText value="#{experimentBean.ID}"></h:outputText> 
      </h:panelGrid> 
      <h:panelGrid columns = "2"> 
       <h:outputText value="Experiment Name"></h:outputText> 
       <h:inputText value="#{experimentBean.name}"></h:inputText> 
      </h:panelGrid> 
      <h:panelGrid columns = "2"> 
       <h:outputText value="Experiment Description"></h:outputText> 
       <h:inputText value="#{experimentBean.description}"></h:inputText> 
      </h:panelGrid> 
      <h:panelGrid columns = "2"> 
       <h:outputText value="Experiment Date"></h:outputText> 
       <h:outputText value="#{experimentBean.date}"></h:outputText> 
      </h:panelGrid> 

      <h:commandButton value="create" action="#{experimentBean.setAOT}"/> 

      <h:panelGrid rendered="#{experimentBean.addObjective}" columns="2"> 
       <h:outputText value="Objective Description"></h:outputText> 
       <h:inputText value="#{experimentBean.EOD}"></h:inputText> 
      </h:panelGrid> 

      <h:commandButton rendered="#{experimentBean.addObjective}" value="add" action="#{experimentBean.addAction}"/> 

      <h:dataTable value="#{experimentBean.EOList}" var="eo"> 
       <h:column> 
        <f:facet name ="header">Objective ID</f:facet> 
        #{eo.ID}   
       </h:column> 
       <h:column> 
        <f:facet name ="header">Objective Description</f:facet> 
        #{eo.description} 
       </h:column> 
       <h:column> 
        <f:facet name ="header">Objective Met</f:facet> 
        #{eo.met} 
       </h:column> 
       <h:column> 
        <h:commandButton value="Delete" action="#{experimentBean.deleteAction}"> 
         <f:setPropertyActionListener target="#{experimentBean.EO}" value="#{eo}"/> 
        </h:commandButton> 
       </h:column> 
      </h:dataTable> 
     </h:form> 
</html> 

登錄

<!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:ui="http://java.sun.com/jsf/facelets" 
     xmlns:h="http://java.sun.com/jsf/html" 
     xmlns:f="http://java.sun.com/jsf/core"> 

      <h:form> 
       <h:panelGrid columns="2"> 
        <h:outputText value="Name"></h:outputText> 
        <h:inputText value="#{loginBean.name}"></h:inputText> 
        <h:outputText value="Password"></h:outputText> 
        <h:inputSecret value="#{loginBean.password}"></h:inputSecret> 
       </h:panelGrid> 
       <h:commandButton value="Login" action="login"></h:commandButton> 
      </h:form> 
    </html> 

歡迎

<!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:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core"> 

     <h:outputLabel value="Welcome #{loginBean.name}"></h:outputLabel> 
     <h:form> 
      <h:panelGrid columns = "3"> 
       <h:outputText value="Ontology Name"></h:outputText> 
       <h:inputText value="#{ontologyBean.name}"></h:inputText> 
       <h:commandButton value="Add" action="#{ontologyBean.addAction}"/> 
      </h:panelGrid> 

      <h:dataTable value="#{ontologyBean.ontologyList}" var="o"> 
       <h:column> 
        <f:facet name ="header">Ontology Name</f:facet> 
        #{o.name} 

       </h:column> 
       <h:column> 
        <h:commandButton value="Start" action="experiment"/> 
       </h:column> 
       <h:column> 
        <h:commandButton value="Delete" action="#{ontologyBean.deleteAction}"> 
         <f:setPropertyActionListener target="#{ontologyBean.ontology}" value="#{o}"/> 
        </h:commandButton> 
       </h:column> 
      </h:dataTable> 
     </h:form> 
</html> 

回答

0

找到答案!必須刪除舊的工作區,重新創建一個項目並重新創建項目。令人煩惱,但它的作品!