2014-04-03 33 views
3

我一直在閱讀關於新Sling Taglib版本1.3的這篇文章http://sling.apache.org/documentation/bundles/sling-scripting-jsp-taglib.html,因爲我想開始使用像listChildren這樣的新JSTL函數,以便我可以避免使用Java scriptlet我的組件。在CQ5.6.1項目中使用Sling Taglib 1.3版

當我使用taglib聲明

<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling" %> 

在我的組件JSP,當我把組件放入我的PARSYS我收到以下錯誤

org.apache.sling.api.scripting.ScriptEvaluationException: 
org.apache.sling.scripting.jsp.jasper.JasperException: 
The absolute uri: http://sling.apache.org/taglibs/sling cannot be resolved 
in either web.xml or the jar files deployed with this application 

在我的Maven pom.xml文件中我有依賴關係

<dependency> 
    <groupId>org.apache.sling</groupId> 
    <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId> 
    <version>2.2.0</version> 
    <scope>provided</scope> 
</dependency> 

該項目生成正確,並正確安裝。

有誰知道如何配置一個CQ 5.6.1項目使用Sling Taglib 1.3版軟件包版本2.2.0與URI http://sling.apache.org/taglibs/sling

回答

4

CQ 5.6.1包含版本2.1.8中的org.apache.sling.scripting.jsp.taglib捆綁包(它在版本1.2中定義了taglib)。爲了使用新的taglib,您需要升級軟件包。

如果您將一個Maven依賴項定義爲provided,這意味着它已經安裝在目標平臺上。在這種情況下,這不是事實。刪除範圍或將其更改爲compile以將新taglib捆綁包包含到CQ包中。軟件包安裝後,您可以使用所有新功能。

您也可以手動安裝the bundle(通過Felix控制檯) - 那麼您將不需要任何Maven依賴關係。

請注意,CQ在安裝新的taglib軟件包後可能會無響應。重新啓動實例應該有所幫助。

相關問題