无法在JSP中包含FTL [英] Not able to include ftl in jsp
问题描述
我想在jsp
页面中包含ftl
模板.我该如何实现?
I want to include ftl
template in jsp
page. How can I achieve it?
details.ftl
details.ftl
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div class="page-content-wrapper">
<div class="page-content">
<div class="col-md-12 col-sm-12">
<div class="portlet yellow-crusta box">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-cogs"></i>${entityType} Details
</div>
<div class="actions">
<a href="javascript:;" class="btn btn-default btn-sm">
<i class="fa fa-pencil"></i> Edit </a>
</div>
</div>
<div class="portlet-body">
<#list detailsMap?keys as key>
<div class="row static-info">
<div class="col-md-5 name">
${key}
</div>
<div class="col-md-7 value">
: ${detailsMap[key]}
</div>
</div>
</#list>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
myPage.jsp
myPage.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page session="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<jsp:include page="sidebar.jsp"/>
<jsp:include page="details.ftl"/>
<body>
推荐答案
为此,与jsp
-s一样,ftl
文件必须具有可访问的URL(尽管从外部不可访问).一种方法是使用FreemarkerSerlvet
(请参见 http://freemarker.org/docs/pgui_misc_servlet .html ).您必须找到答案的另一个问题是,什么将提供数据模型.对于FreemarkerSerlvet
,数据模型来自Servlet请求,会话和应用程序上下文的属性.
For that the ftl
file has to have a visitable URL (though not visitable from outside for security), similarly as jsp
-s have. One way of doing that is by using the FreemarkerSerlvet
(see http://freemarker.org/docs/pgui_misc_servlet.html). Another question you have to find answer for is if what will provide the data-model. In the case of FreemarkerSerlvet
, the data-model is from the attributes of the Servlet request, session, and application context.
这篇关于无法在JSP中包含FTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!