我有一个类,其中包含构造函数和重载方法。当我尝试使用 blazeds 导入该类时,我收到一条错误消息
[RPC Fault faultString="Unable to create a new instance of type 'some class'." faultCode="Server.ResourceUnavailable"
faultDetail="Types cannot be instantiated without a public, no arguments constructor."]
如何使用 blazeds 导入具有重载方法的类
最佳答案
您必须提供“无参数”构造函数。请参阅Converting data from ActionScript to Java .
public class SomeClass
{
// no-args constructor is required for BlazeDS
public SomeClass() {}
public SomeClass(int arg) {}
}
public class SomeService
{
public Connection getConnection()
{
// implement to create or get a connection
}
public void saveSomeClass(SomeClass sc) throws SQLException
{
Connection conn = getConnection();
Statement stmt = conn.createStatement();
String sql = "INSERT INTO some_table (...) VALUES (...)";
stmt.executeUpdate(sql);
stmt.close();
}
}
关于apache-flex - 无法创建类型为 'some class' 的新实例。如果没有公共(public)、无参数的构造函数,则无法实例化类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5153857/