2

cfinvokeを使用せずにCFCで静的メソッドを呼び出すにはどうすればよいですか?私はこれができることを知っています:

<cfinvoke component="MyComponent" method="myStaticMethod' arg1="blah" returnvariable=myReturnVar>

UDFと同じ方法でこのメソッドを呼び出せるようにしたいと思います。

<cfset myReturnVar = MyComponent.myStaticMethod(blah)>

ただし、これは機能しません。私が台無しにしている構文はありますか、それともこれは不可能ですか?

4

2 に答える 2

5

ColdFusion には「静的メソッド」がないため、不可能です。

あなたの質問の<cfinvoke>行は次と同じです:

myReturnVar = CreateObject("component", "MyComponent").myStaticMethod(arg1="blah");
于 2010-01-15T19:20:55.823 に答える
3

最初にオブジェクトを作成する必要があります。

<cfset MyComponent = createObject("component","MyComponent") />
<cfset myReturnVar = MyComponent.myMethod(blah) />
于 2010-01-15T19:56:25.003 に答える