gpt4 book ai didi

coldfusion - 自定义标签和 cfimport

转载 作者:行者123 更新时间:2023-12-01 11:09:57 25 4
gpt4 key购买 nike

自定义标记是否与映射一起使用?我尝试不必将 CustomTags 文件夹作为相对地址进行寻址。

我试过:

<cfset this.mappings["/CT"] = Expandpath("/myProjects/Project1/CustomTags")>

Application.cfc 内部

<cfimport prefix="tag" taglib="/CT">

在我的页面内部,但它没有。

它说:

无法导入/CT 指定的标签库。遇到以下错误:C:\Inetpub\wwwroot\CT。确保您指定了有效的标签库。

最佳答案

与 Jayson 报告的相反 - 我让 CFIMPORT 工作得很好,每个应用程序映射与在 CFAdmin 中全局设置的映射。 CFIMPORT 对映射相当古怪(例如,您不能将变量用于相对路径,也不能使用扩展路径)——但您应该能够执行您要求的操作而不会出现问题。

您是否在 CFAdmin 中选中了“启用每个应用程序设置”?允许您使用 this.mappings 的设置?你运行的是什么版本的 CF?我将 CF8 与此代码一起使用,没有任何问题:

应用程序 CFC(在函数之外但在组件中):

this.rootPath = getDirectoryFromPath(getCurrentTemplatePath());  // this assures path of application.cfc is used to determine path, likely equivalent to expandPath("/")
structInsert(this.mappings, '/vp', this.rootPath);

在 CFC 中(在函数之外但在组件中):

<cfimport prefix="loader" taglib="/vp/view/_loader/">

然后我可以在 CFC 中使用它,它按预期工作。

关于coldfusion - 自定义标签和 cfimport,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1038626/

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