尝试在tomcat中查看html文件时出现404错误

时间:2012-07-11 13:33:46

标签: tomcat

我是tomcat的新手。我刚刚开始阅读第一篇关于servlet的书。我已经安装了tomcat,我可以在// http:// localhost:8080 / examples /下查看内容。这本书提到要创建一个名为" beer"在tomcat的webapps文件夹下。然后在此文件夹中放置.html文件和包含web.xml文件的WEB-INF文件夹。但是,当我尝试运行// http:// localhost:8080 / beer时,我收到404错误。我已经阅读了stackoverflow的另一篇文章,建议添加一个jsp文件,但书中没有提到这个以显示.html文件。有什么建议非常感激吗?

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

1 个答案:

答案 0 :(得分:0)

确保在您的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文件名应该在那里。