[英]How does Apache Sling script resolving rules work?
我的內容名稱為tst
頁面
sling:resourceType = news-portal/pages/test
頁面結構(在/apps
):
測試了
sling:resourceSuperType = news-portal/pages/news-repo-main-page
在瀏覽器中我鍵入以下URL:
http://localhost:4502/cf#/content/tst.selector.pdf.html
在此請求之后,我看到了selector.jsp
內容
但我希望看到selector.pdf.jsp
內容,因為根據我的觀點,它更適合。
你能解釋它是如何工作的嗎?
是否有可以顯示selector.pdf.jsp
內容的URL?
sling:resourceType
而不是sling:resourceSuperType
還是一起? (我嘗試測試但看不到感情) PS
我知道答案在這里:
但我理解上有問題
PS
日志解析:
0 (2014-03-28 13:18:31) TIMER_START{Request Processing}
0 (2014-03-28 13:18:31) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message>
0 (2014-03-28 13:18:31) LOG Method=GET, PathInfo=/content/tst.selector.pdf.html
0 (2014-03-28 13:18:31) TIMER_START{ResourceResolution}
0 (2014-03-28 13:18:31) TIMER_END{0,ResourceResolution} URI=/content/tst.selector.pdf.html resolves to Resource=JcrNodeResource, type=cq:Page, superType=null, path=/content/tst
0 (2014-03-28 13:18:31) LOG Resource Path Info: SlingRequestPathInfo: path='/content/tst', selectorString='selector.pdf', extension='html', suffix='null'
0 (2014-03-28 13:18:31) TIMER_START{ServletResolution}
0 (2014-03-28 13:18:31) TIMER_START{resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/tst)}
0 (2014-03-28 13:18:31) TIMER_END{0,resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/tst)} Using servlet /libs/foundation/components/primary/cq/Page/Page.jsp
0 (2014-03-28 13:18:31) TIMER_END{0,ServletResolution} URI=/content/tst.selector.pdf.html handled by Servlet=/libs/foundation/components/primary/cq/Page/Page.jsp
0 (2014-03-28 13:18:31) LOG Applying Requestfilters
0 (2014-03-28 13:18:31) LOG Calling filter: org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter
0 (2014-03-28 13:18:31) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
0 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter
0 (2014-03-28 13:18:31) LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
0 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.theme.impl.ThemeResolverFilter
0 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet
1 (2014-03-28 13:18:31) LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter
1 (2014-03-28 13:18:31) LOG RedirectFilter did not redirect (MobileUtil.isMobileResource() returns false)
1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.warp.TimeWarpFilter
1 (2014-03-28 13:18:31) LOG Applying Componentfilters
1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
1 (2014-03-28 13:18:31) TIMER_START{/libs/foundation/components/primary/cq/Page/Page.jsp#0}
1 (2014-03-28 13:18:31) LOG Including resource JcrNodeResource, type=news-portal/pages/test, superType=null, path=/content/tst/jcr:content (SlingRequestPathInfo: path='/content/tst/jcr:content', selectorString='selector.pdf', extension='html', suffix='null')
1 (2014-03-28 13:18:31) TIMER_START{resolveServlet(JcrNodeResource, type=news-portal/pages/test, superType=null, path=/content/tst/jcr:content)}
1 (2014-03-28 13:18:31) TIMER_END{0,resolveServlet(JcrNodeResource, type=news-portal/pages/test, superType=null, path=/content/tst/jcr:content)} Using servlet /apps/news-portal/pages/news-repo-main-page/selector.jsp
1 (2014-03-28 13:18:31) LOG Applying Includefilters
1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
1 (2014-03-28 13:18:31) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
1 (2014-03-28 13:18:31) TIMER_START{/apps/news-portal/pages/news-repo-main-page/selector.jsp#1}
2 (2014-03-28 13:18:31) LOG Found processor for post processing ProcessorConfiguration: {contentTypes=[text/html],order=-1, active=true, valid=true, processErrorResponse=true, pipeline=(generator=Config(type=htmlparser, config={}), transformers=(Config(type=linkchecker, config={}), Config(type=mobile, config=org.apache.sling.jcr.resource.JcrPropertyMap@25c0b221), Config(type=mobiledebug, config=org.apache.sling.jcr.resource.JcrPropertyMap@deea7e4), Config(type=contentsync, config=org.apache.sling.jcr.resource.JcrPropertyMap@2f5070e1), serializer=Config(type=htmlwriter, config={}))}
2 (2014-03-28 13:18:31) TIMER_END{1,/apps/news-portal/pages/news-repo-main-page/selector.jsp#1}
2 (2014-03-28 13:18:31) TIMER_END{1,/libs/foundation/components/primary/cq/Page/Page.jsp#0}
2 (2014-03-28 13:18:31) TIMER_END{2,Request Processing} Request Processing
我注意到,如果我創建以下結構並發送請求
http://localhost:4502/cf#/content/tst.selector.pdf.html
我看到了pdf.jsp
內容
在Sling中有兩件事:內容(存儲在/content
)和代碼(存儲在/apps
)。 內容僅包含屬性數據。 /content
下不應該有邏輯,沒有JSP(或任何其他代碼)和選擇器信息。
另一方面, /apps
子樹包含用於呈現內容的腳本。 此類腳本通常稱為組件 。 sling:resourceType
屬性(在/content
下為一段數據設置)是內容和組件之間的鏈接。 這就是內容如何說“應該使用以下組件來展示我”的方式。
sling:resourceSuperType
具有不同的功能。 它是在組件資源上設置的屬性(在/apps
),用於標記此組件應繼承JSP和另一個組件。 此屬性允許創建組件層次結構。
根據注釋中的鏈接,還可以將sling:resourceSuperType
放在/content
下的數據組件中。 在這種情況下,我們強制 sling:resourceType
引用的組件繼承自sling:resourceSuperType
引用的組件。 我不知道任何用例,很難。
在您的情況下,請嘗試創建以下結構:
/content/test
sling:resourceType
= news-portal/pages/test
/apps/news-portal/pages/test
/apps/news-portal/pages/test/test.jsp
/apps/news-portal/pages/test/selector.jsp
/apps/news-portal/pages/test/selector/pdf.jsp
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.