将 FreeMarker 与 Apache Sling 结合使用
我正在使用一个内容存储库 (Adobe CQ5),下面有 Apache Sling。我想使用 FreeMarker 而不是 JSP 来呈现网页。
为此,我应该将 OSGi Freemarker 扩展上传到 Sling(可以在 Sling 源代码的贡献部分中找到),还是应该上传 OSGi 版本的 Freemarker?这两个 jar 都实现了 javax.script.ScriptEngineFactory 接口,所以我不知道使用哪一个,或者同时上传两个。
I'm using a Content Repository (Adobe CQ5) that has Apache Sling underneath. I'd like to render web pages using FreeMarker instead of JSP.
For that to work should I upload the OSGi Freemarker extension to Sling, which is to be found in the contribution part of Sling source code, or should I upload an OSGi version of Freemarker instead? Both jars implement the interface javax.script.ScriptEngineFactory so I don't know which one to use, or to upload both.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过执行以下操作设法让 Freemarker 在 CQ5.3 上工作:
我的做法略有不同,方法是在 CQ5 内创建捆绑包,导入代码并将库存 freemarker.jar 添加到捆绑包中,但这应该也可以工作,因为它基本上是相同的事情。
我遇到的问题是脚本引擎确实被列出,但日志记录阻止它运行,这就是为什么您需要删除日志和日志。来自引擎的 slf4j。
I managed to get Freemarker working on CQ5.3 by doing the following:
I did it slightly differently by creating the bundle inside CQ5, importing the code and adding a stock freemarker.jar into the bundle but this should work too as it's basically the same thing.
The problem I had was that the script engine does get listed but the logging prevents it from running, that's why you need to remove the log & slf4j from the engine.
我不知道 Freemarker 的 OSGi 版本;我们专门为 Sling 创建了自己的 Freemarker 捆绑包。如果您成功使用 OSGi 版本的 Freemarker,请告诉我们;-)
测试很简单:只需通过 Web 控制台安装捆绑包,并在 Web 控制台中检查支持的脚本引擎配置状态。。如果您看到那里列出了 Freemarker 引擎,那么它应该可以工作。
I don't know about the OSGi version of Freemarker; we created our own bundling of Freemarker specially for Sling. If you have success using the OSGi version of Freemarker let us know ;-)
Testing is easy: Just install the bundle through the Web Console and check for the supported Script Engines in the Web Console Configuration Status. If you see the Freemarker Engine listed there, it should work.