Apache Velocity 和 Apache Sling 集成
我正在使用一个内容存储库 (Adobe CQ5),下面有 Apache Sling。我想使用速度模板而不是 JSP 来呈现网页。我设法将速度脚本引擎添加到 felix 控制台,现在我的速度模板正在运行。但我现在很震惊,不知道如何进一步进行..我想知道如何将java对象传递给速度模板,在哪里放置这些java程序以及脚本引擎将如何检测它..如果有人熟悉请帮助我这种情况。
提前致谢
I'm using a Content Repository (Adobe CQ5) that has Apache Sling underneath. I'd like to render web pages using velocity templates instead of JSP. i managed to add velocity script engine to felix console and now my velocity templates run. but im struck now and dunno how to proceed further..i would like to know how to pass java objects to velocity templates,where to place those java programs and how will the script engine detect it..pls help me if anyone is familiar with this situation.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Sling Bindings 机制允许您使对象可用于您的(速度或其他)脚本。
我认为 https://cwiki.apache.org/SLING/adding-new -scripting-variables.html 包含您需要的信息,如有疑问,最好在 Sling 用户邮件列表上询问,请参阅 http://sling.apache.org/site/project-information.html
将 Java 逻辑作为 OSGi 服务提供是使其可供脚本使用的最佳方式,然后脚本可以获取此类通过诸如
sling.getService(java_class)
之类的调用来提供服务。The Sling Bindings mechanism allows you to make objects available to your (velocity or other) scripts.
I think https://cwiki.apache.org/SLING/adding-new-scripting-variables.html has the information that you need, in case of doubt best is to ask on the Sling users mailing list, see http://sling.apache.org/site/project-information.html
Supplying your Java logic as OSGi services is the best way to make it available to scripts, which can then grab such services with calls like
sling.getService(java_class)
.