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

标签 tomcat

我是 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/

相关文章:

java - 我在哪里可以得到 jWebSocketTCPEngine-1.0.jar

java - Windows Server 2012、Apache Tomcat、Spring MVC : Websocket connection blocked for external IP

tomcat - Spring、Tomcat @HandleTypes 注解错误

java - 对tomcat的套接字http请求,但响应302

java - JNDI 失败,出现 javax.naming.NameNotFoundException :Name [jdbc/Database] is not bound in this Context when deploying Spring Boot2 Tomcat 9 NO EMBEDDED

java - 如果它不是 'dynamic web app',如何在 eclipse 中对 Tomcat 运行 WAR?

spring-boot - 来自 Tomcat 的 Spring Boot 配置文件位置

apache - 有没有人在 OSX 上安装了 Tomcat 客户端

java - 服务器启动时在 Web 应用程序中获取服务器端口

java - 运行 Apache DefaultHttpClient 并在 Tomcat 中重新部署 Web 应用程序意味着 Permgen 空间