gpt4 book ai didi

aem - Sling 解析脚本调用顺序

转载 作者:行者123 更新时间:2023-12-01 23:49:36 28 4
gpt4 key购买 nike

我正在查看 sling 如何根据 url 调用脚本。在选择器的情况下,它似乎工作正常,但如果我不使用选择器,我会感到困惑:

我有一个页面 /content/AEMProject/English/test.html 有 resourceType AEMProject/components/page/basepage 资源基页有 4 个脚本文件:basepage.html.jsp、basepage.jsp、html.jsp、GET.jsp。我红了 Sling Best Match 的概念。所以我有两个奇怪的案例。

1) 我的 basepage.html.jsp 正在执行,因为我认为它是最佳匹配。如果我删除此文件 html.jsp 执行,但我认为 basepage.jsp 是第二好的情况。

2) 如果我删除 basepage.html.jsp 、 basepage.jsp 、 html.jsp 文件,我的 GET.jsp 不会呈现。

我在这里考虑底页作为选择器或 IS 不是。

谢谢

最佳答案

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

  • The more request selectors are matched, the better.

(请注意,不会选择具有多个选择器的脚本,即,如果您有脚本 x.y.jsp,其中 x 和 y 是您的选择器,sling 会忽略它。但它仍会选择脚本 y.jsp,存在于文件夹 x 中,即,如果请求是针对 test.x.y.html,则

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

那么现在回答你的问题,

  1. 您的 html.jsp 将始终优先于您的 component.jsp,而不是相反。

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

关于aem - Sling 解析脚本调用顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27213555/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com