java - 找不到网页 HTTP 404 - JSF 页面
问题描述
我是 JSF 的新手,需要帮助来解决问题。我正在创建简单的项目(JSFForm)。
当我执行该项目时,它显示了以下消息。
找不到网页 - HTTP 404。
在 URL 上:http://localhost:8080/JSFForm/faces/index.xhtml。
我已经包含了 jsf-api-2.2.2.jar和javax.faces-2.2.8.jar库。
我正在使用Apache Tomcat 9。
这是index.xhtml代码:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</h:head>
<h:body>
<h:form>
<h:inputText/>
<h:inputTextarea/>
<h:inputSecret/>
<h:inputHidden/>
</h:form>
</h:body>
</html>
这是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>JSFForm</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>
</web-app>
这是faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
version="2.3">
</faces-config>
这是我在 Eclipse 上使用的引用库的屏幕截图:
这是运行程序后在浏览器上查看页面源的屏幕截图:
这是Java 构建路径的屏幕截图:
这是Project Facets的屏幕截图:
解决方案
推荐阅读
- android - 同步调用中的 Android runOnUiThread()
- c - Visual Studio 无法读取结构的某些成员的内存。
- arrays - 如何创建一个包含 5 个值的数组/切片,所有值都相同
- perforce - Perforce 文件全部删除
- javascript - 发送回函数时如何接收 res.send(req.body)
- javascript - 更改数组中的索引值
- docker - 在另一个容器中以 docker-compose 开头的容器无法访问
- wordpress - wordpress 档案出现在谷歌搜索中
- javascript - document.body.appendChild 和 append(var) 不显示/渲染
- c++ - 按给定的存在名称列表对对象列表进行排序