如何将文件从资源路径包含到我的 jsp 文件中?具体路径应该是什么。使用 @include
或 jsp:include
。
我的目录结构:
我想包含 resources/static/template/index.html
home.jsp
中的包含路径。
最佳答案
您不应该在 WEB-INF
的任何子目录中包含 .jsp 文件,并且如果 webapp
是您的 Web 应用程序的上下文根,则您无法包含其之外的任何内容,因为 include 指令和标准标记仅适用于上下文根目录下的文件。
如果您要将整个 resources
目录移动到 webapp
下,那么您将能够使用以下其中一项:
<%@include file="/resources/static/template/index.html"%>
或者
<jsp:include page="/resources/static/template/index.html"/>
关于java - JSP - 包含资源文件夹中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46178466/