【问题标题】:Getting HTTP Status 404 error when trying to deploy war file of my web application on tomcat尝试在 tomcat 上部署我的 Web 应用程序的 war 文件时出现 HTTP 状态 404 错误
【发布时间】:2014-01-03 04:30:11
【问题描述】:

我知道之前有人问过这个问题,但给出的任何答案都没有解决我的问题。

我在 Eclipse 中使用 JSP 创建了一个名为 JSP_web_application_01 的 Web 应用程序,并且我使用的是 ubuntu 12.04 LTS。我在 WebContent 目录中有 index.jsp 文件。我使用命令提示符制作了它的 .war 文件,为了部署它,我将它放在 tomcat 的 webapps 文件夹中,并使用命令 sudo $CATALINA_HOME/bin/shutdown.sh 停止 tomcat 并再次通过 sudo $CATALINA_HOME/ 启动它bin/startup.sh

它膨胀了 .war 文件(JSP_web_application_01.war)并创建了 JSP_web_application_01 文件夹结构和所有内容,但当我尝试使用以下方式从浏览器访问它时得到的是 http 404 状态代码:

http://localhost:8080/JSP_web_application_01/

我明白了:

HTTP Status 404 - /JSP_web_application_01/
type Status report
message /JSP_web_application_01/
description The requested resource is not available.
Apache Tomcat/7.0.47

这是我在 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://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
    <display-name>JSP_web_application_01</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>
</web-app>

这是我第一次尝试托管 Web 应用程序。因此,任何帮助将不胜感激。

【问题讨论】:

  • “我使用命令提示符制作了它的 .war 文件”是什么意思?

标签: eclipse jsp tomcat


【解决方案1】:

您的 Steps 似乎还可以,将欢迎文件列表替换为单个文件,如果要加载 index.html 。那么,

<?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_3_0.xsd" id="WebApp_ID" version="3.0">
    <display-name>JSP_web_application_01</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

在将项目部署为 .war 之前,还要清理并构建项目以消除错误

阅读 herehere 以了解有关部署描述符的更多信息。

希望对你有帮助!

【讨论】:

    【解决方案2】:

    检查项目文件必须在JSP_web_application_01下解压,尤其是index.jsp。如果正确,重启网络服务器,在 $CATALINA_HOME/logs 下跟踪日志文件,检查启动信息是否正确。

    【讨论】:

      猜你喜欢
      • 2023-03-23
      • 2018-09-02
      • 2016-11-15
      • 2011-03-23
      • 2021-02-08
      • 2011-03-22
      • 2022-07-07
      • 2012-12-01
      • 2018-08-24
      相关资源
      最近更新 更多