用ssm框架做的项目,后台调用接口时老是报接口的空指针异常

java.lang.NullPointerException
at edu.tinzel.SSM.biz.impl.StusBizImpl.selectById(StusBizImpl.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

我的逻辑层接口报错的位置是这样的

@Override

public Stus selectById(int id) {

return this.stusmapper.selectById(id);

}

stusmapper没有初始化?

参数有传吗?打断点看一下抛异常的位置

你的sql语句在查询的时候可以用ifnull(exper1,exper2)做null值判断,查询值为null时给它赋个默认值即可。

建议你把你这几个参数封装成 一个对象,通过对象传值

这个对象StusBizImpl没有初始化,是否使用Spring IOC依赖注入的?