ColdFusion:已定义,但抛出未定义错误
<cfif ISDEFINED("CALLER.VARIABLES.STRFUNCNAME")>
<cfparam name="strFuncName" default="#EVALUATE(CALLER.VARIABLES.STRFUNCNAME)#" />
<cfelse>
<cfparam name="strFuncName" default="" />
</cfif>
此代码位于我们的 CustomTags 之一中,并在 EVALUATE 行上引发错误。我不确定这怎么可能。
我可以从调用页面执行此操作以查看变量是否已定义:
<cfset VARIABLES.strFuncName = "strFuncName#intModule#"> <!--- intModule = 1188 --->
#VARIABLES.strFuncName#: #EVALUATE(VARIABLES.strFuncName)# <!--- strFuncName1188: Main --->
<CF_CUSTOMTAG> <!--- Tell me Variable strFuncName1188 is undefined. --->
<cfif ISDEFINED("CALLER.VARIABLES.STRFUNCNAME")>
<cfparam name="strFuncName" default="#EVALUATE(CALLER.VARIABLES.STRFUNCNAME)#" />
<cfelse>
<cfparam name="strFuncName" default="" />
</cfif>
This code is in one of our CustomTags and is throwing an error on the EVALUATE line. I'm not sure how that's even possible.
I can do this from the calling page to see that the variable is defined:
<cfset VARIABLES.strFuncName = "strFuncName#intModule#"> <!--- intModule = 1188 --->
#VARIABLES.strFuncName#: #EVALUATE(VARIABLES.strFuncName)# <!--- strFuncName1188: Main --->
<CF_CUSTOMTAG> <!--- Tell me Variable strFuncName1188 is undefined. --->
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将您的代码更改为:
Change your code to this:
终于弄清楚了......
CALLER.VARIABLES.STRFUNCNAME 只返回“strFuncName####”。因此,对其进行评估是在当前处理范围中查找变量“strFuncName####”,而不是在调用者上。
我将 cfparam 更改为以下内容,它开始工作:
Finally figured it out…
CALLER.VARIABLES.STRFUNCNAME was only returning "strFuncName####". So doing an evaluate on that was looking for the variable "strFuncName####" it in the current processing scope, not on the CALLER.
I changed the cfparam to the following and it began working: