Sling Resolution script calling order

北慕城南 提交于 2020-01-04 04:14:07

问题


I was looking over how sling will call the script on the basis of url. In the case of selector it seems work fine but if i use no selector, its confusing for me to understand:

I have a page /content/AEMProject/English/test.html which has resourceType AEMProject/components/page/basepage resouce basepage has 4 script files : basepage.html.jsp , basepage.jsp , html.jsp, GET.jsp . I red the Sling Best Match concept. So i have two strange cases.

1) My basepage.html.jsp is executing, as i consider it as best match. In case i delete this file html.jsp execute but i consider basepage.jsp as the 2nd best case.

2) In case i delete basepage.html.jsp , basepage.jsp , html.jsp files my GET.jsp doesn't render.

I am considering here basepage as selector or IS is not.

Thanks


回答1:


Quoting from the sling docs the rules for script path priorization is defined as follows:

  • The more request selectors are matched, the better.

(Note that a script with more than one selector doesn't get selected i.e, if you have a script x.y.jsp, where x and y are your selectors, it is ignored by sling. But it would still select the script y.jsp, present inside a folder x i.e., If the request is for test.x.y.html, then

-basepage
 |_x
   |_y.jsp (selected)
 |_x.y.jsp (ignored)
 |_x.jsp (selected in case x/y.jsp is not present. The script containing the first selector is chosen in such cases.)
  • A script including the request extension matches better than one without a request extension (for html only)

  • A script found earlier matches better than a script found later in the processing order. This means, that script closer to the original resource type in the resource type hierarchy is considered earlier.

So now to answer your questions,

  1. Your html.jsp would always take preference over your component.jsp, not the other way round.

  2. Your GET.jsp should execute in the worst case scenario, i.e., when none of the other files are present, unless you have inherited this from some other component.



来源:https://stackoverflow.com/questions/27213555/sling-resolution-script-calling-order

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!