日期:2014-05-19  浏览次数:20631 次

求助啊java.lang.ClassCastException
用的struts1,TestAction继承BaseAction,在BaseAction中的execute方法里走到BaseForm bf = (BaseForm) form;就报错了。
可能是什么引发的呢??

------解决方案--------------------
子类是可以强转父类的,
父类强转子类当然要报错了。。。

BaseForm bf = (BaseForm) form;
你这里的form是ActionForm,
而ActionForm是BaseForm的父类,
也就是说你想把父类的实例强转成子类的,
那是不行的。