Struts、Spring项目跳到InvocationTargetException(Throwable target)方法

最近在使用Struts、Spring开发项目的过程中,出现了一个很奇怪的问题,在执行Action类中的方法时,不能返回数据,debug后发现进入方法后会跳到下边的这个类的方法中,然后控制台报NullPointerException错误

/**
* Constructs a InvocationTargetException with a target exception.
*
* @param target the target exception
*/
public InvocationTargetException(Throwable target) {
   super((Throwable)null);  // Disallow initCause
   this.target = target;
}

原因:在spring中没有配置实现类,所以dao没有注入。调用方法的时候会调用invoke()方法,这个时候dao为null,所以会报错

解决办法:

1.把该dao实现类在spring中的SqlMapConfig.xml配置一下,

<sqlMap resource="com/jiaonizuoren/dao/ibatis/sqlmap/video/VideoSource.xml"/>

2.配置后还是没解决,最后发现是在applicationContext.xml 也没有配置bean标签 Dao和IbatisDao,配置完成后就成功解决了

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值