我是 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 文件中的撇号不正确
最佳答案
确保在您的 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 文件名应该在那里。
关于tomcat - 尝试在tomcat中查看html文件时出现404错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11433823/