我試圖使用HTML壓縮機標籤庫中的Maven https://mvnrepository.com/artifact/com.googlecode.htmlcompressor/htmlcompressor/1.4HTML縮小6.0
使用HTML縮小我添加了下面的依賴關係的pom.xml
<dependency>
<groupId>com.googlecode.htmlcompressor</groupId>
<artifactId>htmlcompressor</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.yahoo.platform.yui</groupId>
<artifactId>yuicompressor</artifactId>
<version>2.4.6</version>
</dependency>
下面是我的header.jsp
<%@include file="/apps/itchotelsonline/components/global.jsp"%>
<%@page import ="com.itc.hotels.services.ItcOnlineConfigurationService" %>
<%@ taglib uri="http://htmlcompressor.googlecode.com/taglib/compressor"
prefix="compress"%>
<%
ItcOnlineConfigurationService onlineConfigService = sling.getService(com.itc.hotels.services.ItcOnlineConfigurationService.class);
if(onlineConfigService != null){
String rootPagePath = onlineConfigService.getRootPagePath();
slingRequest.setAttribute("rootPagePath",rootPagePath);
}
%>
<compress:html removeIntertagSpaces="true" enabled="true" removeComments="false" compressJavaScript="true" yuiJsDisableOptimizations="true">
<cq:include path="${rootPagePath}/jcr:content/header" resourceType="itchotelsonline/components/content/header"/>
<div class="modal fade in new-modal" id="loginOverlayPopup" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body text-center">
<center>
<p><strong id="loginInactivityPopUp"> You are Logged Out due to Inactivity! </strong></p>
</center>
<div class="clear"></div>
<div class="newBook clearfix">
<button type="button" class="btn btn-default" id="loginInactivityBtn" data-dismiss="modal" onclick="resetLoginInactivityPopUp();">Close</button>
</div>
</div>
</div>
</div>
</div>
其中我加了compress html行和taglibs。
<%@ taglib uri="http://htmlcompressor.googlecode.com/taglib/compressor"
prefix="compress"%>
<compress:html removeIntertagSpaces="true" enabled="true" removeComments="false" compressJavaScript="true" yuiJsDisableOptimizations="true">
下面是我的footer.jsp中
<%@include file="/apps/itchotelsonline/components/global.jsp"%>
<%@page import ="com.itc.hotels.services.ItcOnlineConfigurationService" %>
<%
ItcOnlineConfigurationService onlineConfigService = sling.getService(com.itc.hotels.services.ItcOnlineConfigurationService.class);
if(onlineConfigService != null){
String rootPagePath = onlineConfigService.getRootPagePath();
pageContext.setAttribute("rootPagePath",rootPagePath);
}
%>
<cq:include path="${rootPagePath}/jcr:content/footer" resourceType="itchotelsonline/components/content/footer"/>
</compress:html>
我結束了在此。絕對URI:
給Maven構建全新安裝我收到以下錯誤
org.apache.sling.scripting.jsp.jasper.JasperException後http://htmlcompressor.googlecode.com/taglib/compressor不能在在web.xml或罐子解決在org.apache.sling.scripting.jsp.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)部署該應用 文件
我試圖重新啓動AEM實例,並刷新束但是這並沒有解決這個問題。 我想在我的AEM網站上實現HTML縮小。我已經檢查了一天CQ HTML庫管理器,但它只壓縮CSS和JS,而不是通過AEM中的JSP呈現的HTML。 AEM中是否有替代方法可以使用,或者可以使用html壓縮器而不會出現上述錯誤? 請提前建議並提前致謝。
****新的編輯******
我進口圖書館作爲OSGi包,但現在它扔了一個類型轉換exception.I發現htmlcompressor未壓縮的JSP,但是需要純HTML進行壓縮,頁面速度mod是一種可能的選擇,但CSS和JS已經被Day CQ HTML Library Manager縮小了,並且我們還通過更改httpd.conf中的緩存配置來利用瀏覽器緩存。我唯一的要求是HTML縮小。是否有任何庫可以與AEM集成並用於相同的?
我嘗試使用OSGI包,但該庫似乎無法與JSP一起使用。你能否建議一個可以與AEM一起使用的替代庫,用於HTML縮小,並且可以與JSP一起使用,而不僅僅是HTML?我正在研究granule https://github.com/JonathanWalsh/Granule,但是如何將它集成到AEM ? –
@AdityaAuradkar對不起,我不知道圖書館會這樣做,我不知道你爲什麼想。將代碼庫重構爲Sightly模板時會發生什麼?僅供參考,你可以配置mod_pagespeed只刪除空白,如果你願意。 – mickleroy