1
任何人都可以提供從Adobe CQ 5.6上部署的JSP中訪問EL功能的指導嗎?訪問Adobe CQ 5.6中的EL功能,未找到TLD
我的JSP位於一個包中,而我有EL函數(Java類中的靜態方法)和位於單獨的OSGi包中的關聯TLD。兩者都安裝到Adobe CQ。 捆綁包的POM做出口相關的Java包:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>AIB UI Bundle</Bundle-Name>
<Export-Package>
mypackage.*
</Export-Package>
<Include-Resource>
{maven-resources}
</Include-Resource>
<Embed-Dependency>joda-convert;scope=compile|runtime,joda-time;scope=compile|runtime,</Embed-Dependency>
<Bundle-Resource>/META-INF/tags</Bundle-Resource>
<Sling-Bundle-Resource>/META-INF/tags</Sling-Bundle-Resource>
</instructions>
</configuration>
</plugin>
然而,當JSP被處理時,調用EL函數失敗。
錯誤讀取: 文件 「/應用/ AIB /貸款/組件/頁/主/ utilityFunction」 找不到
我的代碼如下。感謝所有的幫助。
Regards, Ken。
EL Function類,位於OSGi包,src/main/java/mypackage/UtilityFunction.java
:
package mypackage;
public class UtilityFunction {
private UtilityFunction() {
...
}
public static String displayBuildNumber() {
// Do processing
}
}
TLD,位於同一OSGi包,
src/main/resources/META-INF/utilityExpressionLanguageFunctions.tld
<?xml version="1.0" encodeing="ISO-8859-1" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.0</tlib-version>
<uri>utilityFunction</uri>
<function>
<name>displayBuildNumber</name>
<function-class>mypackage.UtilityFunction</function-class>
<function-signature>String displayBuildNumber()</function-signature>
</function>
</taglib>
JSP,位於
/apps/myproj/components/page/main/head.jsp
:
<%@include file="/libs/foundation/global.jsp"%><%
%><%@page session="false" %>
<%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %>
<%@taglib prefix="utils" uri="utilityFunction" %>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="keywords" content="<%=properties.get("p_metaKeywords","") %>" />
<meta name="description" content="<%=properties.get("p_metaDescription","") %>" />
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>My Application ${utils:displayBuildNumber()}</title>
<cq:include script="/libs/wcm/core/components/init/init.jsp"/>
<cq:include script="/libs/wcm/core/browsermap/browsermap.jsp" />
<cq:includeClientLib css="jquery-ui" />
<cq:includeClientLib js="cq.jquery, cq.foundation-main, cq.shared, forms-overlay, jquery-ui,cq.jquery.ui" />
</head>
<cq:defineObjects />
如果問題不在你的軟件包安裝,我認爲uri可能需要更像這個''<%@ taglib prefix =「ex」uri =「WEB-INF/custom.tld」%>' – bfitzpatrick