为什么找不到我包含的 JSP?

发布于 2024-12-01 14:51:54 字数 476 浏览 1 评论 0原文

main.jsp 位于 Web 应用程序的此目录中:

/WEB-INF/jsps/foo/section/main.jsp

main.jsp 包含以下代码行,用于尝试包含 mainInclude 中包含的代码。 jsp 在不同的目录中找到:

<jsp:include page="/WEB-INF/jsps/foo/includes/mainInclude.jsp" />

但是,这会生成以下错误:

javax.servlet.ServletException: 
File '/WEB-INF/jsps/foo/includes/mainInclude.jsp' not found 

为什么找不到这个?我检查了位置,它出现在它所说的位置。

The main.jsp is location in this directory of the web app:

/WEB-INF/jsps/foo/section/main.jsp

main.jsp contains the following line of code to try to include the code contained in mainInclude.jsp which is found in a different directory:

<jsp:include page="/WEB-INF/jsps/foo/includes/mainInclude.jsp" />

However, this generates the following error:

javax.servlet.ServletException: 
File '/WEB-INF/jsps/foo/includes/mainInclude.jsp' not found 

Why is this not found? I checked the location and it appears where it says it is.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烦人精 2024-12-08 14:51:54

像这样更改您的 jsp include 标记

<jsp:include page="../includes/mainInclude.jsp" />

应该可以工作。检查 eclipse 是否进入 foo 目录,否则再放一个 ../

Change your jsp include tag like this

<jsp:include page="../includes/mainInclude.jsp" />

That should work. Check the eclipses if they are taking to the foo directory else put one more ../ there.

情愿 2024-12-08 14:51:54

一切看起来都很好。如果您收到该错误,则仅意味着路径中存在拼写错误(区分大小写!),或者该文件实际上尚未发布/部署到服务器中,或者服务器实际上需要重新启动。

如果您正在使用 Eclipse/Tomcat 进行开发,并且您刚刚在 Tomcat 运行时添加了该文件,那么您需要确保 Tomcat 配置为在运行时发布更改。为此,请双击“服务器”视图中的 Tomcat 条目,转到右上角的“发布”部分,并确保其设置如下:

在此处输入图像描述


即默认设置为从不自动发布

Everything looks fine. If you get that error then it simply means that you've a typo in the path (case sensitive!), or that the file actually isn't been published/deployed into the server, or that the server actually needs to be restarted.

If you're developing with for example Eclipse/Tomcat and you just added that file while Tomcat is running, then you need to ensure that Tomcat is configured to publish changes while running. To achieve that, doubleclick Tomcat's entry in Servers view, head to the Publishing section on the right top and make sure that it's set as follows:

enter image description here


It's namely by default set to Never publish automatically.

爱人如己 2024-12-08 14:51:54
This should work <jsp:include page="/WEB-INF/jsps/foo/includes/mainInclude.jsp"/>
  • 如果问题仍然存在,请正确清理项目。

  • 检查eclipse的服务器设置中是否启用了自动发布。

  • 可以使用项目的WAR文件部署在服务器中来检查Eclipse是否有问题。

    获取 WEB-INF 文件夹路径

This should work <jsp:include page="/WEB-INF/jsps/foo/includes/mainInclude.jsp"/>
  • If the problem still exists clean the project properly.

  • Check whether if the Auto publish is enabled in server settings of eclipse.

  • A WAR file of project can be used to deploy in server to check there is any problem in Eclipse.

    Get the WEB-INF folder path

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文