出现了错误信息Mapper method com.dao.student.addS attemped to return null from a method with a primitive return type (int).
本次报错的原因在于sql语句未查询到数据,返回为null。而我们定义的dao层方法是返回为int,就会出现如下这样的提示:
return null from a method with a primitive return type (int).(试图从具有原始返回类型(int)的方法返回null)
Ingeter是int的包装类,int的初值为0,Ingeter的初值为null
解决方式
将dao层的返回类型改为Integer即可。
public interface studentDao{
int addS(Student student)
}
public interface studentDao{
integer addS(Student student)
}