尝试查看tomcat中的html文件时发生404错误
问题描述:
我是tomcat的新手。我刚开始阅读headfirst的servlets书。我已经安装了tomcat,并且能够查看// http:// localhost:8080/examples /下的内容。该书提到在tomcat的webapps文件夹下创建一个名为“beer”的文件夹。然后在该文件夹中放置.html文件和WEB-INF文件夹,其中包含web.xml文件。但是,当我尝试运行// http:// localhost:8080/beer时,出现404错误。我已经从stackoverflow阅读另一篇文章,建议添加一个jsp文件,但本书没有提到这显示.html文件。任何建议非常感谢?尝试查看tomcat中的html文件时发生404错误
最终解决了这个错误。它是由在线复制代码造成的简单解析错误。撇号是在web.xml文件中不正确
答
确保在web.xml文件必须在欢迎文件列表标记HTML文件的声明。像
<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文件中? – 2012-07-11 14:19:03
我是否需要.jsp文件才能显示/呈现html页面? – 2012-07-11 14:23:05