You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Tomcat服务器中JSF无法访问,调用.xhtml页面出现404错误

Tomcat中访问XHTML页面出现404资源未找到问题

在Tomcat Web服务器中调用.xhtml页面时,出现404资源未找到错误。

我的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"
         version="4.0">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <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>
  • 项目结构:[项目结构截图]
  • 容器部署情况:[容器部署截图]

尝试过以下访问路径均返回资源未找到:

  • localhost/amazonlite/cart.xhtml
  • localhost/cart.xhtml
  • localhost/amazonlite/faces/cart.xhtml
  • http://localhost:8080/faces/cart.xhtml

内容的提问来源于stack exchange,提问作者chhu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 23:12:05