【发布时间】:2011-11-24 05:15:57
【问题描述】:
我正在尝试使用 FreeMarker 使用 servlet 编写复杂的网页。
页面有 3 个基本组件:顶部的导航栏、左侧的广告栏和中间的主要内容部分。我有一个单独的 servlet 来绘制其中的每一个。每个 servlet 只生成一个 html5 部分,可能使用也可能不使用 freemarker。
以上所有内容当然都在使用 freemarker 模板化的主网页中。
问题是这样的。 主页的模板看起来像这样(为简单起见,条纹很多):
<html>
<body>
<!--lots of stuff in between-->
<section-nav> <!--this should be filled by output of NavServlet.respond -->
<!--lots of stuff in between-->
<section-content> <!-- this comes from arbitrary servlet for actual content -->
<section-advertise> <!--this should be filled by output of AdvertiseServlet -->
</body>
</html
如何使用 FreeMarker 处理上述结构? 如果我为主页执行 template.process() ,它将同时编写 html 开始和结束标记,但我想要的是让其他 servlet(导航、广告等)有机会在 html 结束标记之前生成内容。
如果我们不能为此使用 FreeMarker,我也可以使用其他模板解决方案。
【问题讨论】:
标签: java servlets freemarker