Coldfusion this.mappings在cfc中不起作用 - >功能
如何获取我在application.cfc中定义的映射以在其他cfcs中的其他函数中工作?
即this.mappings [“plugins”]在任何页面上都可以正常工作但如果我尝试实例化一个包含调用this.mappings [“plugins”]的函数的cfc - 它就会失败。
谢谢
编辑:
我不确定 - 这就是我要做的事情:
在application.cfc中:
this.mappings["Plugins"] =
getDirectoryFromPath(getCurrentTemplatePath())&'Assets/Plugins';
并在stock.cfc:
<cfcomponent output="yes" >
<cffunction name="showIndecies" access="public" output="yes" returntype="string">
<cfscript>
j = 1;
variables.indeciesArray = ArrayNew(1);
variables.indeciesFile =
application.mappings["Plugins"]&'/StockMarketData/Data/indecies.csv';
</cfscript>
没有找到相关结果
已邀请:
3 个回复
抵舵
然后通过“插件”在其他代码中引用,所以:
HTH,如果不在调用页面上发布您的代码。
掀辟髓观粟
或
。 您需要直接访问结构的用例是什么?你想修改它吗? *编辑修复代码
坝硷操
它应该是
注意结构键名中的斜杠“/”。您必须以这种方式命名每个映射。 然后你会参考Sam Farmer在评论中提到的映射“ 然后通过“插件”在其他代码中引用,所以: