gpt4 book ai didi

coldfusion - Coldfusion 的 createObject() 函数如何搜索组件?

转载 作者:行者123 更新时间:2023-12-04 18:43:04 24 4
gpt4 key购买 nike

我在理解 createObject() 时遇到了一些问题函数,文档说它的使用类似于 CreateObject("component", component-name) .

在文档中,提到Coldfusion在“ColdFusion Administrator的自定义标签路径页面上指定的目录”中搜索组件

但在我的情况下它不起作用。我在 CF 管理员中为自定义标签映射了一个文件夹,在该文件夹内我放置了一个名为“mycfcs”的文件夹,其中存在我的 cfc,名为 Item.cfc
在测试页面中,我以这种方式创建对象:
<cfset testObj = createobject("component","mycfcs.Item")>
但它抛出错误“ 找不到 ColdFusion 组件或接口(interface) ”。

最佳答案

在 Application.cfc 中创建指向包含 CFC 的文件夹的每个应用程序映射

this.mappings["/cfc"] = {path to your CFCs};

然后在你的 createObject()调用,使用点分隔路径到您的 CFC。
createObject("component", "cfc.Item");

如果您有子文件夹,则可以这样访问它
createObject("component", "cfc.subFolder.Item");

关于coldfusion - Coldfusion 的 createObject() 函数如何搜索组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20584101/

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