如果在我道歉之前有人问过这个问题,但没有一些帮助我无法获得足够的理解......
我有一个本地 ColdFusion9 应用程序,用于在带有 Apache 2 的 WinXP SP3 上运行开发和测试...
我在理解如何调用从应用程序的“THIS”范围传递到 onRequestStart() 方法的请求元素时遇到问题。
例如,我的 Application.cfc 在 'THIS' 中有以下内容......
<!--- MY 'THIS' Statements in Application.cfc --->
<cfscript>
/* define custom coldfusion mappings. Keys are mapping names, values are full paths */
this.mappings = structNew();
this.mappings['/tags'] = ExpandPath('/cfdev/tags');
</cfscript>
在我的 Application.cfc 中,我在 onRequestStart() 函数中有以下内容......
<!--- Run before the request is processed --->
<cffunction name="onRequestStart" returnType="boolean" output="false">
<cfargument name="thePage" type="string" required="true">
<cfinclude template="#arguments.thePage#">
<!--- Lot's of onRequest statements and then ... --->
<cfset request.mappings = #THIS.mappings#>
<cfreturn true>
</cffunction>
现在......假设我有一个页面,我调用 <cfdump var="#request.mappings#"> ...
我收到一条错误消息
'在请求中未定义元素映射。' ...
但是,(这是我的困惑开始的地方)......如果我调用 <cfdump var="#request#"> 返回两个结构......第一个包含“cfdumpinited”的键,值为 'False' 和第二个是 structKey 'mappings',它包含另一个结构,其键为 '/tags',值为 'C:\vir_dir\CFDEV\tags',正如人们所期望的那样......
如果有人可以解释为什么请求成功但 request.mappings 失败了,因为我在这里有点迷茫...... ;-)