在apache tomcat 6服务器上运行时,我的项目将获得404。 localhost8080工作正常,因为我得到了tomcat主页。我的xhtml文件在我的webcontent文件夹中,我相信我的web.xml设置正确。
这是文件:
的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 :(得分:0)
找到答案!必须删除旧工作区,创建一个新工作区并重新创建项目。很麻烦,但它确实有效!