我有一个.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