我正在使用Coldfusion8
并且我试图调用一个组件。这种情况一直持续到几天前,虽然我不记得改变了什么,但我对这个组件的所有调用现在都失败了。
这里是代码:
<cfinvoke component="form_mailer_user" method="msg_contact">
<cfinvokeargument name="userData" value="#Local.User#"/>
</cfinvoke>
除了传递结构之外,没什么特别的。
我收到以下错误:
Could not find the ColdFusion Component or Interface form_mailer_user.
Ensure that the name is correct and that the component or interface exists
它存在,所以我该怎样才能尝试访问它?
感谢您的帮助!
修改
这两个文件都位于名为services
的同一文件夹中。我在application.cfc
THIS.mappings["/services"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "services";
但是试图像这样调用组件:
services.form_mailer_user
services.form_mailer_user.cfc
也行不通。
修改
我的application.cfc
<cfcomponent displayname="Application" output="false" hint="Application handler">
<cfscript>
THIS.name = "abc";
THIS.sessionManagement = "true";
THIS.sessionTimeout = createTimeSpan(0,2,0,0);
THIS.s3.acceesKeyid = "___";
THIS.s3.awsSecretKey = "___";
// mappings
THIS.mapping = {};
THIS.mappings["/controllers"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "controllers";
THIS.mappings["/services"] = GetDirectoryFromPath( GetCurrentTemplatePath() ) & "services";
</cfscript>
<cffunction name="onApplicationStart" returnType="boolean" output="false" hint="">
<cfscript>
Application.strConfig = structNew();
Application.strConfig.datasource = "___";
Application.strConfig.rootDir = "test/members/";
Application.strConfig.emailErrorMessaging = "on";
// pre
Session.activeSession = "No";
Session.activeLog = "No";
</cfscript>
<cfreturn true />
</cffunction>
<cffunction name="onSessionStart" returnType="boolean" output="false" hint="session initalizer">
<cfscript>
var Local = {};
Local.cfid = Session.cfid;
Local.cftoken = Session.cftoken;
StructClear( SESSION );
</cfscript>
<!---SESSION --->
<cfparam name="Session.log" default="">
<cfparam name="Session.activeLog" default="No">
<cfscript>
Session.cfid = Local.cfid;
Session.cftoken = Local.cftoken;
Session.activeSession = "Yes";
Session.datasource = Application.strConfig.datasource;
Session.testpath = "tes/";
Session.tpu = "../";
Session.bucketPath = "http://s3.amazonaws.com/";
Session.bucketName = "___";
</cfscript>
<cfreturn true />
</cffunction>
<cffunction name="onRequestStart" returnType="boolean" output="false" hint="Pre page processing!">
<cfscript>
var LOCAL = {};
</cfscript>
<!--- DEBUG --->
<!---
<cfif structKeyExists(url,'reset')>
<cfcache action="flush">
<cfset OnApplicationStart() />
<cfset THIS.OnSessionStart() />
</cfif>
--->
<cfif len( Session.errMsgs ) EQ 0>
<cfinvoke component="services.errorMsg" method="createErrMsgsLog" returnvariable="errMsgs"></cfinvoke>
<cfset Session.errMsgs = errMsgs>
</cfif>
<cfreturn true />
</cffunction>
<!--- custom functions --->
<cfinclude template="templates/tmp_functions.cfm">
</cfcomponent>
修改:
我想我越来越近了。我有另一个邮件程序(相同的文件夹),我只是换了这个替换我的
<cfinvoke component="form_mailer_other" method="msg_contact">
<cfinvokeargument name="userData" value="#Local.User#"/>
</cfinvoke>
现在Coldfusion找不到方法,但这意味着它找到了cfc。可能是我的mailer.cfc里面的错误吗?
SOLUTION:
我不敢告诉......
文件名中的错字来自 _mailer_user ...感谢大家帮忙!
答案 0 :(得分:3)
如果CFC和CFM文件不在同一目录中,则需要使用点添加CFC所在的目录名称。见下文。 (directory.form_mailer_user)
答案 1 :(得分:1)
在您无法“看到”的方法定义中添加属性 access =“public” :
<cffunction name="onRequestStart" access="public" returnType="boolean" output="false" hint="Pre page processing!"> ...