我尝试在GSP脚本中使用Sling taglib,但导入时出现此错误:
10.11.2015 10:02:41.392 *ERROR* [0:0:0:0:0:0:0:1 [1447146161196] GET /com/test/networks/network_a.html HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught SlingException
groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
GStringTemplateScript1.groovy: 2: unable to resolve class taglib , unable to find class for annotation
@ line 2, column 53.
eturn { out -> out << """"""; @taglib pr
^
1 error
脚本的第一行是:
<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling" %>
我已经安装了Groovy 2.2.4,我在Felix控制台(Script Engines)中看到了它
Available Script Engines
========================
Groovy Scripting Engine 2.0
-------------------------------------
- Language : Groovy, 2.4.5
- Extensions : groovy
- MIME Types : application/x-groovy
- Names : groovy, Groovy
GSPScriptEngineFactory 0
-------------------------------------
- Language : Groovy Scripting Pages, 1.0
- Extensions : gsp
- MIME Types : -
- Names : gsp, GSP
此软件包已安装并启动:
Apache Sling JSP Tag Library org.apache.sling.scripting.jsp.taglib
我错过了什么吗?我查看了可用的文档并试图找到示例,但没有找到很多。
我也尝试过使用JDK 1.8和1.7,结果相同。
在罗伯特的评论之后,我意识到这个捆绑包实际上并没有安装和启动,即使使用groovy-all.jar,我也可以在脚本引擎中看到GSP:{{3} }
此处还有另一个存储库:https://github.com/sling-git/sling/tree/master/contrib/scripting/groovy
但是我已经构建并安装了它,现在我已经在这个捆绑包的控制台中看到了:
Apache Sling Scripting Groovy Support (org.apache.sling.scripting.groovy)
Symbolic Name org.apache.sling.scripting.groovy
Imported Packages groovy.json,version=2.4.5 from groovy-all (124)
groovy.lang,version=2.4.5 from groovy-all (124)
groovy.text,version=2.4.5 from groovy-all (124)
javax.script,version=0.0.0.1_008_JavaSE from org.apache.felix.framework (0)
org.apache.sling.commons.classloader,version=1.3.0 from org.apache.sling.commons.classloader (84)
org.apache.sling.scripting.api,version=2.3.0 from org.apache.sling.scripting.api (107)