【发布时间】:2018-09-30 11:18:16
【问题描述】:
在 Apache Sling 中,我想在 HTML 页面中包含一个 javascript。
通过http://localhost:8080/bin/browser.html/ 我创建了两个节点(然后手动):html.html 和 processing.js。
html.html 的 JSON 是:
{
"jcr:created": "{Date}2018-04-19 20:50:09",
"jcr:createdBy": "admin",
"jcr:primaryType": "{Name}nt:file",
"jcr:content": {
"jcr:data": "/bin/cpm/nodes/property.bin/apps/res/html.html/_jcr_content?name=jcr%3Adata",
"jcr:lastModified": "{Date}2018-04-19 20:50:09",
"jcr:lastModifiedBy": "admin",
"jcr:mimeType": "text/html",
"jcr:primaryType": "{Name}nt:resource",
"jcr:uuid": "ed3121b3-580c-46b2-acc6-7029cdb6f1c3"
}
}
processing.js 的 JSON 是:
{
"jcr:data": "/bin/cpm/nodes/property.bin/apps/res/processing.js?name=jcr%3Adata",
"jcr:lastModified": "{Date}2018-04-19 21:32:40",
"jcr:lastModifiedBy": "admin",
"jcr:mimeType": "text/javascript",
"jcr:primaryType": "{Name}nt:resource",
"jcr:uuid": "74fd137a-3b37-4893-b443-bd086a4fb4d7"
}
在页面 HTML 中,我在
标记中包含带有【问题讨论】:
-
向上。我认为发生这种情况是因为脚本标签不是由 Sling 解释的,而是从浏览器中解释的,然后它将搜索资源而不是找到它(因为它是节点的形式,而不是从浏览器中识别出来的)。但我不知道这是否正确。
-
我解决了。我将 js 插入 etc 文件夹,并将其指向 html。
标签: osgi-bundle apache-felix sling