在 Debian 下“JSP 路径怎么设”通常取决于你用的 Web 服务器 / 容器,最常见的是 Tomcat。下面分情况说明。
标准结构:
/var/lib/tomcat9/webapps/
└── yourapp/
├── index.jsp
├── WEB-INF/
│ └── web.xml
└── css/
yourapp 是应用上下文路径http://服务器IP:8080/yourapp/index.jsp
Debian 常见 Tomcat 版本:
tomcat9tomcat9 或 tomcat10在 WEB-INF/web.xml 中:
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
这样访问:
http://IP:8080/yourapp/
会自动进 index.jsp
配置文件:
/etc/tomcat9/server.xml
改端口:
<Connector port="8080" .../>
<link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet">
避免写死:
<!-- 不推荐 -->
<link href="/yourapp/css/style.css">
如果你用 Apache 转发:
/etc/tomcat9/server.xml
<Connector port="8009" protocol="AJP/1.3" />
ProxyPass /yourapp ajp://localhost:8009/yourapp
❌ 404 原因:
WEB-INF/web.xml检查:
systemctl status tomcat9
journalctl -u tomcat9
请告诉我:
我可以直接给你精确配置示例。