这是我第一次尝试自己建立一个 Web 应用程序项目,出于某种原因,我什至无法让它与 hello world 设置一起工作。我将所有内容都设置为默认值,选择了用于编译的 JDK1.8 和一个带有 index.html 页面的 Tomcat7 服务器,其中只有文本。在将项目添加到服务器后,我应该能够右键单击项目并在服务器上运行,但即使使用这个简单的设置,我仍然会收到 404。我错过了什么?
Web.xml 欢迎列表:
<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>
最佳答案
您不能直接访问WEB-INF 文件夹下的文件。容器会在 WEB-INF/classes 中查找类,WEB-INF 下的 jsp 文件可以被其他 JSP 包含,但是任何浏览器在下面请求资源都会得到 404 响应。
您应该将 index.xhtml 路径从 webapp/WEB-INF/index.html
更改为 webapp/index.html
以对应您的 web.xml
关于java - 设置 Eclipse 动态 Web 应用程序时出现 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26985862/