xxAction继承BaseAction,BaseAction注入了一个CommonManager,BaseAction.commonSave()方法调用了commonManager。

本来想xxAction调用父类的commonSave方法将会导致commonManager为null的错误,因为jvm去初始化BaseAction时并不会去注入CommonManger。
其实解决这个问题只需要在子类xxAction bean配置文件中加上commonManager这个property,然后把父类BaseAction的commonManager 改为protected就 Ok了。这样初始化子类的时候会注入commonManager,调用commonSave方法也就不会抛出npe了。

配置文件中把xxAction 加上parent的配置也是可以的,这样会把父类的所有property都注入
评论
发表评论

您还没有登录,请登录后发表评论

eyejava
搜索本博客
我的相册
5882c820-4b57-4dfd-b8d1-046e88098b0f-thumb
Gmail
共 8 张
存档
最新评论