ActionForm调用service返回空指针问题
我想在ActionForm的reset方法中载入所有的下拉框内容,然后填充到页面上的各个控件中,这个查询用到了Service中的一个查询方法,此查询方法调用Dao,而Dao是通过调用getHibernateTemplate来实现对数据据的访问操作的,结果给返回空指针,此方法在Action中测试过,没有问题!
以下是ActionForm的reset方法中的部分代码:
try { ServicesImpl_F service=new ServicesImpl_F(); //调用Service List<Department> list=service.getDepartment(); //service中一个返回部门信息列表的方法 System.out.println("共有"+list.size()+"个部门"); List<LabelValueBean> deptlists=new ArrayList<LabelValueBean>(); for(int i=0;i<list.size();i++) { String bmbh=list.get(i).getBmbh(); String bmmc=list.get(i).getBmmc(); deptlists.add(new LabelValueBean(bmbh,bmmc)); } this.setDepts(deptlists); //depts是一个List集合变量,返回给JSP界面的<html:options>控件 } catch(Exception e) { System.out.println(e); e.printStackTrace(); }