【发布时间】:2017-09-12 14:00:30
【问题描述】:
如何将文件从资源路径包含到我的 jsp 文件中?具体路径应该是什么。使用@include 或jsp:include。
我的目录结构:
我想包含resources/static/template/index.html home.jsp 中的包含路径。
【问题讨论】:
标签: java spring jsp spring-mvc war
如何将文件从资源路径包含到我的 jsp 文件中?具体路径应该是什么。使用@include 或jsp:include。
我的目录结构:
我想包含resources/static/template/index.html home.jsp 中的包含路径。
【问题讨论】:
标签: java spring jsp spring-mvc war
您不应该在WEB-INF 的任何子目录中包含 .jsp 文件,如果 webapp 是您的 Web 应用程序的上下文根,则您无法在它之外包含任何内容,因为 include 指令和标准标签仅适用于上下文根目录下的文件。
如果您要将整个resources 目录移动到webapp 下,那么您将能够使用以下方法之一:
<%@include file="/resources/static/template/index.html"%>
或者
<jsp:include page="/resources/static/template/index.html"/>
【讨论】:
WEB-INF/views 下,这是不好的做法吗?
web.xml 中指定一个 url 模式,否则您将无法浏览它
我已经这样解决了
【讨论】:
尝试使用:
<%@include file="../../resources/static/template/index.html" %>
【讨论】: