我正在学习 Java EE,所以我从 JSP 开始。我设置了我的 eEclipse 环境,并运行了一个简单的项目。当我尝试运行项目时,Tomcat 找不到我的 JSP 文件。我把我的 JSP 文件放在 WebContent
文件夹下,但是 Tomcat 仍然找不到它。
我不明白为什么它不起作用。我是否将我的文件放在其他地方?我将 web.xml
保留为默认值:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Test</display-name>
<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>
</welcome-file-list>
</web-app>
最佳答案
从屏幕截图中,您尝试访问 http://localhost:8080/Test.jsp
,但我猜应用程序可以在 /Test
路径上访问;所以你必须访问:
http://localhost:8080/Test/Test.jsp
您可以在 Eclipse 上从 Web Project Settings -> Context root
选项卡上的项目属性中查看和更改此基本路径名称。
默认值为项目名称。
关于java - Tomcat 找不到 JSP 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23087248/