我想从表中获取DEVICES的数量并在我的Html页面上显示结果,我有以下代码,当我运行此代码时,我在我的bean中得到Null指针异常:
DashboardDaoImp.java // Dao实现
public int getNumberOfDevices(){
return DataAccessUtils.intResult(getHibernateTemplate().find("SELECT COUNT(DISTINCT deviceid) from Device"));
}
DashboardDao.java // Dao界面
public interface DashbordDao {
int getNumberOfDevices();
}
DashboardBoImp.java // Bo实现
DashbordDao dashbordDao;
@Override
public int getNumberOfDevices() {
return dashbordDao.getNumberOfDevices();
}
DashboardBoImp.java // Bo界面
public interface DashbordBo {
int getNumberOfDevices();
}
DashboardBean.java //我的bean
public int getNumberOfDevices()
{
samssnb_device = dashboardBo.getNumberOfDevices();
return samssnb_device;
}
//我的Html页面
<h3>#{dashbord.getNumberOfDevices()}<sup style="font-size: 20px"></sup></h3>
<p>Number of devices </p>
//堆栈跟踪