Freemarker 不打印 html 内容
我开始编写一些 Freemarker 代码,但遇到问题。
假设我的 FTL 如下所示:
<#list datas as x>
Name : ${x.name}
< /#list>
在 Eclipse 控制台中,我得到了正确的结果,但浏览器中没有打印任何内容。我有 HTML 模板,但我的 BODY 之间没有任何内容。
你知道出了什么问题吗?
多谢 !
I begin some Freemarker code but I have a problem.
Let's say that my FTL is like the following:
<#list datas as x>
Name : ${x.name}
< /#list>
In Eclipse console I have the correct result but nothing is printing in my browser. I have the HTML Template but nothing between my BODY.
Do you know what's going wrong ?
Thanks a lot !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您要传递给
Template.process
的是什么Writer
?您应该将HttpResponse
的Writer
传递给它,或者最终将其输入写入其中的东西。如果在 FreeMarker 中显式禁用了自动刷新(可能无论如何都没有),并且您没有在 Writer 上调用刷新,那么也可能会导致类似的问题。另外,请确保
datas
不为空,因为这样上面的模板就不会输出任何内容。究竟是什么打印了 HTML 正文标签?那不是FreeMarker吗?
What
Writer
are you passing toTemplate.process
? You should pass theWriter
of theHttpResponse
to it, or something that eventually writes its input there. If auto-flushing was explicitly disabled in FreeMarker (it probably wasn't anyway) and you don't call flush on theWriter
, that can also lead to issues like this.Also, be sure
datas
is not empty, because then the above template outputs nothing.What prints the HTML body tags anyway? Is that not FreeMarker?