Apache Sling脚本解析规则如何工作?

gst*_*low 6 java sling aem

我的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
Run Code Online (Sandbox Code Playgroud)

在此请求后,我看到了内容 selector.jsp

但我希望看到内容,selector.pdf.jsp 因为根据我的意见它更适合.

  1. 你能解释它是如何工作的吗?

  2. 有可以显示内容的URL selector.pdf.jsp吗?

  3. 内容的选择是否影响测试是 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
Run Code Online (Sandbox Code Playgroud)

UPDATE

我注意到,如果我创建以下结构并发送请求

http://localhost:4502/cf#/content/tst.selector.pdf.html
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我看到了内容 pdf.jsp

Tom*_*wek 7

在Sling中有两件事:内容(存储在下面/content)和代码(存储在下面/apps).内容仅包含属性数据.应该没有逻辑,没有JSP(或任何其他代码)和选择器信息/content.

另一方面,/apps子树包含用于呈现内容的脚本.此类脚本通常称为组件.sling:resourceTypeproperty(为一段数据设置,under /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
    • 主JSP文件
  • /apps/news-portal/pages/test/selector.jsp
    • JSP用于选择器
  • /apps/news-portal/pages/test/selector/pdf.jsp
    • 选择器+ pdf扩展名