[注意:我是java初学者]
我尝试按名称调用对象,然后尝试按名称调用其方法,
但是这段代码抛出异常 java.lang.NoSuchMethodException:
Field mainClassField = mainObject.getClass()
.getField( dataObject.callObject );
/* callObject is an another object */
Object callObject = mainClassField.get( mainObject );
Method callMethod = callObject.getClass()
.getMethod( dataObject.callMethod ); << error on this line
callMethod.invoke(callObject, dataObject);
[注意:我通过 AMF 从 actionscript 3 传递 dataObject ]
调用对象代码:
public class UserCallController extends Controller {
public void getUserById(DataTransferObject dataObject) {
Ppvchat mainClass = _inst._mainClass;
dataObject.data.put("userData",
mainClass.userModel.getById( dataObject.data.getString("id") ));
}
}
谢谢。