【问题标题】:404 error while trying to view html file in tomcat尝试在 tomcat 中查看 html 文件时出现 404 错误
【发布时间】:2012-07-11 13:33:45
【问题描述】:

我是 tomcat 的新手。我刚刚开始阅读 headfirst 的 servlets 书。我已经安装了tomcat,并且可以在//http://localhost:8080/examples/下查看内容。书中提到要在tomcat的webapps文件夹下创建一个名为“beer”的文件夹。然后在此文件夹中放置 .html 文件和包含 web.xml 文件的 WEB-INF 文件夹。但是,当我尝试运行 //http://localhost:8080/beer 时,出现 404 错误。我已经阅读了 stackoverflow 的另一篇文章,该文章建议添加一个 jsp 文件,但书中没有提到这一点来显示 .html 文件。任何建议非常感谢?

最终解决了这个错误..这是一个简单的从网上复制代码导致的解析错误。 web.xml 文件中的撇号不正确

【问题讨论】:

    标签: tomcat


    【解决方案1】:

    确保在您的 web.xml 文件中,您的 html 文件在欢迎文件列表标记中声明 .like

    <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>
    

    你的 html 文件名应该在那里。

    【讨论】:

    • 嘿 neeraj 感谢您的回复。 html 文件保存为 index.html 所以我假设我不需要将此内容添加到 web.xml 文件中??
    • 我需要一个 .jsp 文件来显示/渲染 html 页面吗?
    猜你喜欢
    • 2016-11-14
    • 1970-01-01
    • 1970-01-01
    • 2021-03-30
    • 1970-01-01
    • 2015-01-20
    • 2012-11-26
    • 2019-12-05
    • 2019-08-04
    相关资源
    最近更新 更多