为什么找不到我包含的 JSP?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像这样更改您的 jsp include 标记
应该可以工作。检查 eclipse 是否进入 foo 目录,否则再放一个 ../ 。
Change your jsp include tag like this
That should work. Check the eclipses if they are taking to the foo directory else put one more ../ there.
一切看起来都很好。如果您收到该错误,则仅意味着路径中存在拼写错误(区分大小写!),或者该文件实际上尚未发布/部署到服务器中,或者服务器实际上需要重新启动。
如果您正在使用 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:
It's namely by default set to Never publish automatically.
如果问题仍然存在,请正确清理项目。
检查eclipse的服务器设置中是否启用了自动发布。
可以使用项目的WAR文件部署在服务器中来检查Eclipse是否有问题。
获取 WEB-INF 文件夹路径
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