为什么我不能在 Coldfusion 组件中调用方法?



我正在使用Coldfusion8,并且在尝试调用组件时遇到了问题。这一直持续到几天前,尽管我记不起更改过什么,但我对该组件的所有调用现在都失败了。

这里的代码:

<cfinvoke component="form_mailer_user" method="msg_contact">
     <cfinvokeargument name="userData" value="#Local.User#"/>
</cfinvoke>  

除了传递一个structare参数之外,没有什么特别的。

我得到以下错误:

 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

也不起作用。

编辑:
我的应用程序.cc

<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内部的错误吗?

解决方案:
我不敢告诉。。。

从_mailer_user键入文件名。。。感谢大家的帮助!

如果CFC和CFM文件不在同一目录中,则需要用点添加CFC所在的目录名。请参见下文。(directory.form_mailer_user)

在你看不到的方法的定义中添加属性access="public"

<cffunction name="onRequestStart" access="public" returnType="boolean" output="false" hint="Pre page processing!"> ...

最新更新