使用ssh框架开发遇到的空指针问题
小弟在ssh项目开发的遇到了空指针的问题,尚未发现解决方法,望各路大神相助
是在添加私信的时候出的问题,私信(privateletter)和用户(user)是多对一关系,已经在many-to-one关系后面加上了lazy=false
Action中:public String addprivateletter(){
revuser=privateletterService.userById(revuser.getUserId());
user=privateletterService.userById(user.getUserId());
privateletterService.addprivateletter( privateletter,user ,revuser);
return "Success";
}
其中privateletterService.addprivateletter( privateletter,user ,revuser);函数是传递user,revuser两个usertable型变量
DaoImpl中:
public void addprivateletter(PrivateletterTable privateletter,
UserInfoTable user, UserInfoTable revuser) {
privateletter.setUserInfoTableByUserId(user);
privateletter.setUserInfoTableByRevuserId(revuser);
this.getHibernateTemplate().save(privateletter);
}
我是在前台jsp页面上点击我的粉丝的头像让后将对应的userId和revuserId(就是粉丝的Id)传到addprivateletter函数,在DaoImpl层可以输出对应的userId和revuserId,但是privateletter.setUserInfoTableByUserId(user)函数报出空指针错误,大意是说user没有初始化,找几天没找出答案,还请大神帮帮忙。