吊索解析脚本调用顺序 [英] Sling Resolution script calling order

查看:75
本文介绍了吊索解析脚本调用顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究吊索将如何基于url调用脚本。在选择器的情况下,它似乎工作正常,但如果我不使用选择器,它会使我难以理解:

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:

我有一个页面 / content /AEMProject/English/test.html 具有resourceType AEMProject / components / page / basepage 资源基页有4个脚本文件: basepage.html.jsp,basepage.jsp,html.jsp,GET.jsp 。我对Sling Best Match概念充满信心。所以我有两个奇怪的情况。

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)我执行的 basepage.html.jsp 正在执行最佳搭配。如果我删除此文件 html.jsp 执行,但我认为 basepage.jsp 是第二好的情况。

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)如果我删除了 basepage.html.jsp,basepage.jsp,html.jsp 我的 GET.jsp 无法呈现。

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

我在这里考虑将基准页作为选择器,或者IS不在。

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

谢谢

推荐答案

sling docs 脚本路径优先级的规则定义如下:

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



  • 匹配的请求选择器越多越好。

(请注意,具有多个选择器的脚本不会被选择,即,如果您有一个脚本xyjsp,其中x和y是您的选择器,但仍会选择脚本 y.jsp ,该脚本位于文件夹 x ,即,如果请求是test.xyhtml,则

(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.)





  • 包含请求扩展名的脚本比没有请求扩展名的脚本更好(仅适用于html)

  • 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. 您的html.jsp始终会优先于

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

您的GET.jsp应该在最坏的情况下执行,即,当没有其他文件当前,除非您已经从其他组件继承了它。

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.

这篇关于吊索解析脚本调用顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆