Not able to include ftl in jsp

纵饮孤独 提交于 2019-12-08 06:39:56

问题


I want to include ftl template in jsp page. How can I achieve it?

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

<%@ 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>

回答1:


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.



来源:https://stackoverflow.com/questions/31003817/not-able-to-include-ftl-in-jsp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!