首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache脚本解析规则是如何工作的?

问Apache脚本解析规则是如何工作的?
EN

Stack Overflow用户
提问于 2014-03-28 08:53:35
回答 1查看 3.5K关注 0票数 6

我在内容中有一个名为tst的页面

sling:resourceType = news-portal/pages/test

页面结构(在/apps下):

​

​

测试过

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

在browser I中,键入以下URL:

代码语言:javascript
复制
http://localhost:4502/cf#/content/tst.selector.pdf.html

在这个请求之后,我看到了selector.jsp的内容

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

  1. 你能解释一下它的工作原理吗?
  2. 是否有显示selector.pdf.jsp内容的网址?
  3. 内容的选择是否会影响测试是否有sling:resourceType而不是sling:resourceSuperType或者一起?(我试着测试,但看不到感情)

附注:

我在这里知道这个答案:

​

​

但我很难理解

P.S.

日志解析:

代码语言:javascript
复制
      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

更新

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

代码语言:javascript
复制
http://localhost:4502/cf#/content/tst.selector.pdf.html

​

​

我看到了pdf.jsp的内容

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-28 14:12:59

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

另一方面,/apps子树包含用于呈现内容的脚本。这样的脚本通常称为组件。sling:resourceType属性(为一段数据设置,在/content下)是内容和组件之间的链接。这就是内容可以说“下面的组件应该用来显示我”的方式。

sling:resourceSuperType具有不同的功能。它是组件资源(在/apps下)上的一个属性集,用于标记该组件应该继承JSP并从另一个组件继承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扩展

​

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22708055

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档