简体   繁体   English

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

[英]How does Apache Sling script resolving rules work?

I have page with name tst in content whose 我的内容名称为tst页面

sling:resourceType = news-portal/pages/test

page structure (under the /apps ): 页面结构(在/apps ):

在此输入图像描述

test has 测试了

sling:resourceSuperType = news-portal/pages/news-repo-main-page

in browser I type following URL: 在浏览器中我键入以下URL:

http://localhost:4502/cf#/content/tst.selector.pdf.html

after this request I see content of selector.jsp 在此请求之后,我看到了selector.jsp内容

But I expected to see content of selector.pdf.jsp because it has more suitable much according my opinion. 但我希望看到selector.pdf.jsp内容,因为根据我的观点,它更适合。

  1. Can you explain how it works? 你能解释它是如何工作的吗?

  2. Is there URL which can show content of selector.pdf.jsp ? 是否有可以显示selector.pdf.jsp内容的URL?

  3. Does the choice of content affects if test had sling:resourceType instead of sling:resourceSuperType or together? 内容的选择是否会影响测试是否具有sling:resourceType而不是sling:resourceSuperType还是一起? (I try to test but don't see affection) (我尝试测试但看不到感情)

PS PS

I know that answer somewhere here: 我知道答案在这里:

在此输入图像描述

But I have problems with understanding 但我理解上有问题

PS PS

log resolving: 日志解析:

      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

UPDATE UPDATE

I noticed that if I create following structure and send request to 我注意到,如果我创建以下结构并发送请求

http://localhost:4502/cf#/content/tst.selector.pdf.html

在此输入图像描述

I see content of pdf.jsp 我看到了pdf.jsp内容

In Sling there are two things: content (stored under /content ) and code (stored under /apps ). 在Sling中有两件事:内容(存储在/content )和代码(存储在/apps )。 Content contains only properties data. 内容仅包含属性数据。 There should be no logic, no JSP (or any other code) and selector information under /content . /content下不应该有逻辑,没有JSP(或任何其他代码)和选择器信息。

On the other hand, /apps subtree contains scripts used to render the content. 另一方面, /apps子树包含用于呈现内容的脚本。 Such scripts are usually called components . 此类脚本通常称为组件 sling:resourceType property (set for a piece of data , under /content ) is a link between content and component. sling:resourceType属性(在/content下为一段数据设置)是内容和组件之间的链接。 This is the way how content may say "following component should be used to display me". 这就是内容如何说“应该使用以下组件来展示我”的方式。

sling:resourceSuperType has a different function. sling:resourceSuperType具有不同的功能。 It is a property set on the component resource (under /apps ), used to mark that this component should inherit JSPs and from another one. 它是在组件资源上设置的属性(在/apps ),用于标记此组件应继承JSP和另一个组件。 This property allows to create component hierarchy. 此属性允许创建组件层次结构。

According to link in the comment it is also possible to put sling:resourceSuperType in the data component under /content . 根据注释中的链接,还可以将sling:resourceSuperType放在/content下的数据组件中。 In this case, we force the component referenced in sling:resourceType to inherit from component referenced in sling:resourceSuperType . 在这种情况下,我们强制 sling:resourceType引用的组件继承自sling:resourceSuperType引用的组件。 I don't know any use-case for that, tough. 我不知道任何用例,很难。

In your case, please try creating following structure: 在您的情况下,请尝试创建以下结构:

  • /content/test
    • sling:resourceType = news-portal/pages/test sling:resourceType = news-portal/pages/test
  • /apps/news-portal/pages/test
    • component main resource, no special properties 组件主资源,没有特殊属性
  • /apps/news-portal/pages/test/test.jsp
    • main JSP file 主JSP文件
  • /apps/news-portal/pages/test/selector.jsp
    • JSP used for selector JSP用于选择器
  • /apps/news-portal/pages/test/selector/pdf.jsp
    • selector + pdf extension 选择器+ pdf扩展名

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM