紧急求助SSH查询出现空指针错误
谢了一个SSH的查询,但是执行之后页面上报空指针错误!求解:
1.noticeDaoImpl.javapackage com.HRM.dao.Impl;import java.util.List;import org.springframework.orm.hibernate3.support.HibernateDaoSupport;import com.HRM.dao.noticeDao;import com.HRM.entity.Notice;public class noticeDaoImpl extends HibernateDaoSupport implements noticeDao { @Override public List<Notice> findAllNotice() { List<Notice> list = getHibernateTemplate().find("from Notice"); return list; } }2.noticeServiceImpl.javapackage com.HRM.Service.Impl;import java.util.List;import com.HRM.dao.noticeDao;import com.HRM.entity.Notice;import com.opensymphony.xwork2.ActionSupport;public class noticeServiceImpl extends ActionSupport implements noticeService{ private noticeDao ndao; @Override public List<Notice> findAllNotice() { return ndao.findAllNotice(); } public noticeDao getNdao() { return ndao; } public void setNdao(noticeDao ndao) { this.ndao = ndao; }}3.noticeAction.javapackage com.HRM.action;import java.util.List;import javax.servlet.http.HttpSession;import org.apache.struts2.ServletActionContext;import com.HRM.Service.Impl.noticeService;import com.HRM.entity.Notice;import com.opensymphony.xwork2.ActionSupport;public class noticeAction extends ActionSupport { private noticeService nser; HttpSession session = ServletActionContext.getRequest().getSession(); @Override public String execute() throws Exception { List<Notice> list = nser.findAllNotice(); if(list.size()>0){ session.setAttribute("notice",list); return SUCCESS; } return ERROR; } public noticeService getNser() { return nser; } public void setNser(noticeService nser) { this.nser = nser; }}