JSF HTTP状态404–;在Hello world程序中找不到
我试图用jsf制作一个hello world程序。我想在eclipse中运行xhtml文件(我还没有使用Java),但无法启动它。我只得到一般性的错误 HTTP状态404–未找到:说明源服务器未找到目标资源的当前表示形式,或者不愿意透露存在该表示形式 我的其他.jsp文件运行没有问题。当我运行xhtml文件时,这是浏览器中显示的确切链接:有jsf项目的文件:JSF HTTP状态404–;在Hello world程序中找不到,jsf,http-status-code-404,Jsf,Http Status Code 404,我试图用jsf制作一个hello world程序。我想在eclipse中运行xhtml文件(我还没有使用Java),但无法启动它。我只得到一般性的错误 HTTP状态404–未找到:说明源服务器未找到目标资源的当前表示形式,或者不愿意透露存在该表示形式 我的其他.jsp文件运行没有问题。当我运行xhtml文件时,这是浏览器中显示的确切链接:有jsf项目的文件: /JSFProjectHello/WebContent/hello-world.xhtml <!DOCTYPE html>
/JSFProjectHello/WebContent/hello-world.xhtml
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:a="http://xmlns.jcp.org/jsf/passthrough">
<h:head>
<title>Hello World - Input Form</title>
</h:head>
<h:body>
<h:form>
<h:inputText id="name" value="#{theUserName}"
a:placeholder="What's your name?" />
<h:commandButton value="Submit" action="myresponse" />
</h:form>
</h:body>
</html>
所以我最终发现了一个错误。我下载了不正确的库javax.faces-2.2.8-sources.jar,正确的库应该是javax.faces-2.2.8.jar请阅读这里是否正确?我的应用程序中有
web
。请仔细阅读@JasperDeVries发布的链接。faces文件夹是多余的
/JSFProjectHello/WebContent/hello-world.xhtml
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Hello World - Response</title>
</h:head>
<h:body>
Hello, #{theUserName}
</h:body>
</html>
/JSFProjectHello/WebContent/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>JSFProjectHello</display-name>
<welcome-file-list>
<welcome-file>hello-world.xhtml</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>
</web-app>
/JSFProjectHello/WebContent/WEB-INF/lib/javax.faces-2.2.8-sources.jar