无法在 JSP 中包含 WEB-INF 目录中的 javascript 文件。
如何使用tomcat在jsp中包含以下文件夹WEB-INF\includes\header.js中的文件。我已在 jsp 文件中包含以下内容,但它不起作用“
<script type="text/javascript" src="WEB-INF/includes/header.js"></script>
”。它没有获取 header.js,当我查看源代码并尝试单击 src 链接时,它显示资源未找到 404 错误。
How to include a file in the following folder WEB-INF\includes\header.js in jsp using tomcat. I have the included the following in jsp file but it does not work "
<script type="text/javascript" src="WEB-INF/includes/header.js"></script>
". It is not getting the header.js and when i view source and try to click on the src link it says resource not found 404 error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样在
"WEB-INF"
之前放置一个"/"
,这样就可以正常工作了。 :)
Put a
"/"
before"WEB-INF"
like this,and it will work fine. :)
foo.js 位于 WEB-INF/jsp 下,包含它的文件位于 WEB-INF/jsp/common 下
foo.js is under WEB-INF/jsp and the file include it is under WEB-INF/jsp/common