我有一個.cfm
文件用下面的代碼:方法,ColdFusion的11,創建對象
<cfset myObj=CreateObject("java", "Test")/>
<cfset a = myObj.init() >
<cfoutput>
#a.hello()#
</cfoutput>
<cfset b = a.testJava() >
<cfoutput>
#testJava()#
</cfoutput>
此引用Java
類文件:
public class Test
{
private int x = 0;
public Test(int x) {
this.x = x;
}
public String testJava() {
return "Hello Java!!";
}
public int hello() {
return 5;
}
}
我得到的錯誤:
The hello method was not found.
Either there are no methods with the specified method name and argument types or the hello method is overloaded with argument types that ColdFusion cannot decipher reliably.
ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.
我已經嘗試了很多不同的方法,並且完全遵循了文檔,here。 .class
文件是在正確的位置,因爲如果文件被刪除,我將引發FNF錯誤。
我也試圖以類似的方式使用cfobject
標籤,但沒有運氣。沒有找到任何方法。有任何想法嗎?
ColdFusion的11,修復7
這是一個很長的時間,因爲我做的ColdFusion,但並不需要一個參數傳遞給'myObj.init() '以滿足構造參數? –
是的,你會,我沒有參數也試過,沒有運氣。那主要是爲了測試。 – theblindprophet