[英]JSP - Include a file from the resources folder
How do I include a file into my jsp file from the resources path?如何从资源路径将文件包含到我的 jsp 文件中? What should the path be specifically.路径具体应该是什么。 Using either @include
or jsp:include
.使用@include
或jsp:include
。
My directory structure:我的目录结构:
I want to include resources/static/template/index.html
what should be the include path in home.jsp
.我想包含resources/static/template/index.html
应该是home.jsp
的包含路径。
You shouldn't have .jsp files in any subdirectory of WEB-INF
, and if webapp
is the context root of your web application, there's no way you can include anything outside it, since both the include directive and standard tag only work on files under the context root.您不应该在WEB-INF
任何子目录中包含 .jsp 文件,并且如果webapp
是您的 Web 应用程序的上下文根,则您无法在其之外包含任何内容,因为 include 指令和标准标记都仅适用于文件在上下文根下。
If you were to move the whole resources
directory under webapp
, then you'll be able to use one of the following:如果您要将整个resources
目录移动到webapp
下,那么您将能够使用以下方法之一:
<%@include file="/resources/static/template/index.html"%>
Or或者
<jsp:include page="/resources/static/template/index.html"/>
I have solved it like this我已经这样解决了
尝试使用:
<%@include file="../../resources/static/template/index.html" %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.