当前位置:编程学习 > JAVA >>

-------SSH+DWR删除信息问题!---------------------------------------------------请高手赐教!!!

小弟做了一个SSH+DWR的Web程序,从数据库查询到列表信息并显示,可对每一条信息进行修改和删除,通过正常的SSH模式删除某条数据没有问题,可通过DWR在前台直接传ID调用后台的删除方法报错:java.lang.NullPointerException
思前想后不得其解,望高手指点迷津!!! DWR SSH Web --------------------编程问答-------------------- 使用了null进行操作~具体是哪一行代码贴出来~看看是哪个对象null了! --------------------编程问答--------------------
引用 1 楼 hzw2312 的回复:
使用了null进行操作~具体是哪一行代码贴出来~看看是哪个对象null了!


如图:Id的值传进去了,但是获取是报错了!
很是郁闷!!! --------------------编程问答-------------------- 你69的id取到了吗?
TalTargetinfoDAO 中的deleteInfo的190的id 呢?
--------------------编程问答-------------------- 下图是删除方法:

在线等…… --------------------编程问答--------------------
引用 3 楼 rui888 的回复:
你69的id取到了吗?
TalTargetinfoDAO 中的deleteInfo的190的id 呢?

当然取到了啊!图中的AId:12就是。 --------------------编程问答-------------------- 是不是你的事务问题哦,同时提交,也就是你的delete(null); --------------------编程问答-------------------- 你可以先别删除然后调用 find 方法看是否有值返回。 --------------------编程问答--------------------
引用 4 楼 cgw1123 的回复:
下图是删除方法:

在线等……


你应该看看你删除方法中的190行、是不是getHibernateTemplate()为null、或者看看findById方法返回的是不是null..... --------------------编程问答-------------------- 给你两个例子,看看。
http://download.csdn.net/detail/zuxianghuang/4158486 --------------------编程问答--------------------
引用 7 楼 rui888 的回复:
你可以先别删除然后调用 find 方法看是否有值返回。

直接调用findById方法传递Id进去,还是报同样的错。 --------------------编程问答--------------------
引用 8 楼 hzw2312 的回复:
Quote: 引用 4 楼 cgw1123 的回复:

下图是删除方法:

在线等……


你应该看看你删除方法中的190行、是不是getHibernateTemplate()为null、或者看看findById方法返回的是不是null.....

findById方法返回的肯定是null了,因为在69行就报了java.lang.NullPointerException,再想想!多谢了! --------------------编程问答--------------------
引用 11 楼 cgw1123 的回复:
Quote: 引用 8 楼 hzw2312 的回复:

Quote: 引用 4 楼 cgw1123 的回复:

下图是删除方法:

在线等……


你应该看看你删除方法中的190行、是不是getHibernateTemplate()为null、或者看看findById方法返回的是不是null.....

findById方法返回的肯定是null了,因为在69行就报了java.lang.NullPointerException,再想想!多谢了!


把show_sql等于true配置上、把sql打印出来!看看为什么查询出null、直接把sql放到数据库去执行!  --------------------编程问答--------------------
引用 10 楼 cgw1123 的回复:
Quote: 引用 7 楼 rui888 的回复:

你可以先别删除然后调用 find 方法看是否有值返回。

直接调用findById方法传递Id进去,还是报同样的错。

1.要么是你 get方法的类路径错误了。要么是你的事务配置错了
get(类.class,id)在试试呢 --------------------编程问答--------------------
引用 13 楼 rui888 的回复:
Quote: 引用 10 楼 cgw1123 的回复:

Quote: 引用 7 楼 rui888 的回复:

你可以先别删除然后调用 find 方法看是否有值返回。

直接调用findById方法传递Id进去,还是报同样的错。

1.要么是你 get方法的类路径错误了。要么是你的事务配置错了
get(类.class,id)在试试呢

findById方法是自动生成的,路径一点问题没有。至于事务配置你可否详细说说,我想也应该没问题吧。 --------------------编程问答--------------------
引用 12 楼 hzw2312 的回复:
Quote: 引用 11 楼 cgw1123 的回复:

Quote: 引用 8 楼 hzw2312 的回复:

Quote: 引用 4 楼 cgw1123 的回复:

下图是删除方法:

在线等……


你应该看看你删除方法中的190行、是不是getHibernateTemplate()为null、或者看看findById方法返回的是不是null.....

findById方法返回的肯定是null了,因为在69行就报了java.lang.NullPointerException,再想想!多谢了!


把show_sql等于true配置上、把sql打印出来!看看为什么查询出null、直接把sql放到数据库去执行! 

配置show_sql等于true是我的编程习惯,这个真看不出啥问题,直接运行在那就报错了。 --------------------编程问答--------------------
引用 15 楼 cgw1123 的回复:
Quote: 引用 12 楼 hzw2312 的回复:

Quote: 引用 11 楼 cgw1123 的回复:

Quote: 引用 8 楼 hzw2312 的回复:

Quote: 引用 4 楼 cgw1123 的回复:

下图是删除方法:

在线等……


你应该看看你删除方法中的190行、是不是getHibernateTemplate()为null、或者看看findById方法返回的是不是null.....

findById方法返回的肯定是null了,因为在69行就报了java.lang.NullPointerException,再想想!多谢了!


把show_sql等于true配置上、把sql打印出来!看看为什么查询出null、直接把sql放到数据库去执行! 

配置show_sql等于true是我的编程习惯,这个真看不出啥问题,直接运行在那就报错了。


是不是调试的时候没有进入查询方法就出错了? --------------------编程问答--------------------
引用 9 楼 ZuxiangHuang 的回复:
给你两个例子,看看。
http://download.csdn.net/detail/zuxianghuang/4158486

大概看了一下,感觉都没啥问题,运行还是一样出错,还望赐教呐!非常感谢! --------------------编程问答--------------------
引用 16 楼 hzw2312 的回复:
Quote: 引用 15 楼 cgw1123 的回复:

Quote: 引用 12 楼 hzw2312 的回复:

Quote: 引用 11 楼 cgw1123 的回复:

Quote: 引用 8 楼 hzw2312 的回复:

Quote: 引用 4 楼 cgw1123 的回复:

下图是删除方法:

在线等……


你应该看看你删除方法中的190行、是不是getHibernateTemplate()为null、或者看看findById方法返回的是不是null.....

findById方法返回的肯定是null了,因为在69行就报了java.lang.NullPointerException,再想想!多谢了!


把show_sql等于true配置上、把sql打印出来!看看为什么查询出null、直接把sql放到数据库去执行! 

配置show_sql等于true是我的编程习惯,这个真看不出啥问题,直接运行在那就报错了。


是不是调试的时候没有进入查询方法就出错了?

什么意思?我感觉那两张图完全可以说明问题了,就是在69行报错了,你看呢? --------------------编程问答-------------------- hibernate动作都没执行有屁SQL

你的hibernate模板是空。 --------------------编程问答--------------------
引用 18 楼 cgw1123 的回复:
Quote: 引用 16 楼 hzw2312 的回复:

Quote: 引用 15 楼 cgw1123 的回复:

Quote: 引用 12 楼 hzw2312 的回复:

Quote: 引用 11 楼 cgw1123 的回复:

Quote: 引用 8 楼 hzw2312 的回复:

Quote: 引用 4 楼 cgw1123 的回复:

下图是删除方法:

在线等……


你应该看看你删除方法中的190行、是不是getHibernateTemplate()为null、或者看看findById方法返回的是不是null.....

findById方法返回的肯定是null了,因为在69行就报了java.lang.NullPointerException,再想想!多谢了!


把show_sql等于true配置上、把sql打印出来!看看为什么查询出null、直接把sql放到数据库去执行! 

配置show_sql等于true是我的编程习惯,这个真看不出啥问题,直接运行在那就报错了。


是不是调试的时候没有进入查询方法就出错了?

什么意思?我感觉那两张图完全可以说明问题了,就是在69行报错了,你看呢?


你不会一行行设置断点调试吗?如果是上面的69行有问题、那为什么还会进入删除方法输出你的id呢!
就是删除方法190行的问题!你调试看看那一行的对象中哪一个null了! --------------------编程问答-------------------- hibernate模板 是不是null? --------------------编程问答--------------------
引用 20 楼 hzw2312 的回复:
Quote: 引用 18 楼 cgw1123 的回复:

Quote: 引用 16 楼 hzw2312 的回复:

Quote: 引用 15 楼 cgw1123 的回复:

Quote: 引用 12 楼 hzw2312 的回复:

Quote: 引用 11 楼 cgw1123 的回复:

Quote: 引用 8 楼 hzw2312 的回复:

Quote: 引用 4 楼 cgw1123 的回复:

下图是删除方法:

在线等……


你应该看看你删除方法中的190行、是不是getHibernateTemplate()为null、或者看看findById方法返回的是不是null.....

findById方法返回的肯定是null了,因为在69行就报了java.lang.NullPointerException,再想想!多谢了!


把show_sql等于true配置上、把sql打印出来!看看为什么查询出null、直接把sql放到数据库去执行! 

配置show_sql等于true是我的编程习惯,这个真看不出啥问题,直接运行在那就报错了。


是不是调试的时候没有进入查询方法就出错了?

什么意思?我感觉那两张图完全可以说明问题了,就是在69行报错了,你看呢?


你不会一行行设置断点调试吗?如果是上面的69行有问题、那为什么还会进入删除方法输出你的id呢!
就是删除方法190行的问题!你调试看看那一行的对象中哪一个null了!

我说老兄,你是否看清我的代码?程序是先执行删除方法deleteInfo的,输出id后才调用findById方法查询的,再然后findById方法的69行查询报错返回null,才到了deleteInfo的190行。 --------------------编程问答--------------------
引用 19 楼 forgetsam 的回复:
hibernate动作都没执行有屁SQL

你的hibernate模板是空。


引用 21 楼 rui888 的回复:
hibernate模板 是不是null?


还望说详细点,感觉你说的好像里问题很近,小弟也感觉可能是这里的问题,具体的细节不是太懂,还望您不吝赐教!非常感谢!!! --------------------编程问答-------------------- 你的getHibernateTemplate() 是不是null --------------------编程问答--------------------
引用 24 楼 rui888 的回复:
你的getHibernateTemplate() 是不是null

是的,刚调试了一下,getHibernateTemplate()确实null,这个问题要怎么解决?? --------------------编程问答--------------------
引用 25 楼 cgw1123 的回复:
Quote: 引用 24 楼 rui888 的回复:

你的getHibernateTemplate() 是不是null

是的,刚调试了一下,getHibernateTemplate()确实null,这个问题要怎么解决??


ssh框架里的这个模板需要在配置中做注入。
你的原因很可能是你的dwr类根本就没和Spring结合,就是一个普普通通的javaBean里面放了个模板,这样肯定空指针。 --------------------编程问答--------------------
引用 26 楼 forgetsam 的回复:
Quote: 引用 25 楼 cgw1123 的回复:

Quote: 引用 24 楼 rui888 的回复:

你的getHibernateTemplate() 是不是null

是的,刚调试了一下,getHibernateTemplate()确实null,这个问题要怎么解决??


ssh框架里的这个模板需要在配置中做注入。
你的原因很可能是你的dwr类根本就没和Spring结合,就是一个普普通通的javaBean里面放了个模板,这样肯定空指针。

我的spring里也配置过了dwr呀,添加用户验证都是这么验证的都没问题的,删除为啥不行? --------------------编程问答-------------------- 你的spring注入getHibernateTemplate这玩意了么 
也就是说ssh整合有没有成功啊
--------------------编程问答-------------------- 楼主只需要将这个类的spring bean配置文件贴出来 大家就知道了  --------------------编程问答--------------------
引用 28 楼 djy18178 的回复:
你的spring注入getHibernateTemplate这玩意了么 
也就是说ssh整合有没有成功啊


引用 29 楼 zyrobert 的回复:
楼主只需要将这个类的spring bean配置文件贴出来 大家就知道了 

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">

<!-- 配置数据源 -->
<bean id="sessionFactoryID"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:net/zzvc/snmp/config/hibernate.cfg.xml">
</property>
</bean>
<!--<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactoryID" />
</property>
</bean>-->
<!-- DAO层配置 -->
<bean id="TblTargetinfoDAO"
class="net.zzvc.snmp.dao.impl.TblTargetinfoDAO">
<dwr:remote javascript="getInfos"></dwr:remote>
<property name="sessionFactory">
<ref bean="sessionFactoryID" />
</property>
</bean>
<bean id="SnmpDao" class="net.zzvc.snmp.dao.impl.SnmpDao">
<dwr:remote javascript="getSNMPALL"></dwr:remote>
</bean>
<!-- BIZ层配置 -->
     <bean id="TblTargetinfoBiz" class="net.zzvc.snmp.biz.impl.TblTargetinfoBiz">
   <property name="dao" ref="TblTargetinfoDAO"></property>
 </bean>
<!-- ACTION层配置 -->
      <!--用户信息-->
 <bean name="/info" class="net.zzvc.snmp.web.action.TargetAction">
   <property name="biz" ref="TblTargetinfoBiz"></property>
 </bean>
<!--ajax配置-->
<dwr:configuration>
        <dwr:convert class="net.zzvc.snmp.dao.impl.TblTargetinfoDAO" type="bean"></dwr:convert>
<dwr:convert class="net.zzvc.snmp.dao.impl.SnmpDao" type="bean"></dwr:convert>
    </dwr:configuration>
<bean id="TblWarningDAO"
class="net.zzvc.snmp.dao.impl.TblWarningDAO">
<property name="sessionFactory">
<ref bean="sessionFactoryID" />
</property>
</bean>
<bean id="TblInfotypeDAO"
class="net.zzvc.snmp.dao.impl.TblInfotypeDAO">
<property name="sessionFactory">
<ref bean="sessionFactoryID" />
</property>
</bean></beans>
--------------------编程问答--------------------   <!--<bean id="hibernateTemplate"
        class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory">
            <ref bean="sessionFactoryID" />
        </property>
    </bean>--> 
是不是这个被注释的原因!
这些配置我一般都不关注了 
--------------------编程问答--------------------
引用 31 楼 djy18178 的回复:
  <!--<bean id="hibernateTemplate"
        class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory">
            <ref bean="sessionFactoryID" />
        </property>
    </bean>--> 
是不是这个被注释的原因!
这些配置我一般都不关注了 

这个配置本身是没有的,我以前弄的所有项目也都没有这个的,是我昨天听大家这么说就在网上查了一下配了这个,但是也没啥效果,所以有注释掉了。 --------------------编程问答-------------------- 哦 你的hibernate那个模板是由spring管理的吗
没看到你配置hibernate的SessionFactory啊 
你只配置了数据源而已啊 --------------------编程问答-------------------- 给你看看我的配置。。我的hibernate是由spring管理的。。
<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byName" xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://localhost:3306/ngbaojia">
</property>
<property name="username" value="root"></property>
<property name="password" value="charmingyb"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/ngbaojia/entity/Customerinfo.hbm.xml</value>
<value>com/ngbaojia/entity/User.hbm.xml</value>
<value>com/ngbaojia/entity/Offerprice.hbm.xml</value>
<value>com/ngbaojia/entity/Enginner.hbm.xml</value>
<value>com/ngbaojia/entity/Material.hbm.xml</value>
<value>com/ngbaojia/entity/Materialcolumn.hbm.xml</value>
<value>com/ngbaojia/entity/Enginnercolumn.hbm.xml</value>
<value>com/ngbaojia/entity/Master.hbm.xml</value>
<value>com/ngbaojia/entity/Deptmenu.hbm.xml</value>
<value>com/ngbaojia/entity/Department.hbm.xml</value>
<value>com/ngbaojia/entity/Menu.hbm.xml</value>
</list>
</property></bean>
<bean id="UserDao" class="com.ngbaojia.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="UserService" class="com.ngbaojia.service.impl.UserServiceImpl">
<property name="userDao" ref="UserDao"></property>
</bean>
<bean id="UserAction" class="com.ngbaojia.action.UserAction">
     <property name="userService" ref="UserService"></property>
</bean>
<bean id="OfferpriceDao" class="com.ngbaojia.dao.impl.OfferpriceDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="OfferpriceService" class="com.ngbaojia.service.impl.OfferpriceServiceImpl">
<property name="offerpriceDao" ref="OfferpriceDao"></property>
</bean>
<bean id="MaterialcolumnDao" class="com.ngbaojia.dao.impl.MaterialcolumnDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="MaterialcolumnService" class="com.ngbaojia.service.impl.MaterialcolumnServiceImpl">
<property name="materialcolumnDao" ref="MaterialcolumnDao"></property>
</bean>
<bean id="MaterialDao" class="com.ngbaojia.dao.impl.MaterialDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="MaterialService" class="com.ngbaojia.service.impl.MaterialServiceImpl">
<property name="materialDao" ref="MaterialDao"></property>
</bean>
<bean id="masterDao" class="com.ngbaojia.dao.impl.MasterDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="MasterService" class="com.ngbaojia.service.impl.MasterServiceImpl">
<property name="masterDao" ref="masterDao"></property>
</bean>
<bean id="MasterAction" class="com.ngbaojia.action.MasterAction">
    <property name="masterService" ref="MasterService"></property>
</bean>
<bean id="EnginnercolumnDao" class="com.ngbaojia.dao.impl.EnginnercolumnDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="EnginnercolumnService" class="com.ngbaojia.service.impl.EnginnercolumnServiceImpl">
<property name="enginnercolumnDao" ref="EnginnercolumnDao"></property>
</bean>
<bean id="EnginnerDao" class="com.ngbaojia.dao.impl.EnginnerDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="EnginnerService" class="com.ngbaojia.service.impl.EnginnerServiceImpl">
<property name="enginnerDao" ref="EnginnerDao"></property>
</bean>
<bean id="CustomerinfoDao" class="com.ngbaojia.dao.impl.CustomerinfoDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="CustomerinfoService" class="com.ngbaojia.service.impl.CustomerinfoServiceImpl">
<property name="customerinfoDao" ref="CustomerinfoDao"></property>
</bean>
<bean id="MenuDao" class="com.ngbaojia.dao.impl.MenuDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="MenuService" class="com.ngbaojia.service.impl.MenuServiceImpl">
<property name="menuDao" ref="MenuDao"></property>
</bean>
<bean id="DepartmentDao" class="com.ngbaojia.dao.impl.DepartmentDaoImpl">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean><bean id="DepartmentService" class="com.ngbaojia.service.impl.DepartmentServiceImpl">
    <property name="departmentDao" ref="DepartmentDao"></property>
</bean>
<bean id="DeptMenuDao" class="com.ngbaojia.dao.impl.DeptMenuDaoImpl">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="DeptMenuService" class="com.ngbaojia.service.impl.DeptMenuServiceImpl">
    <property name="deptMenuDao" ref="DeptMenuDao"></property>
</bean>
</beans>
--------------------编程问答--------------------
引用 34 楼 charmingyb 的回复:
给你看看我的配置。。我的hibernate是由spring管理的。。
<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byName" xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://localhost:3306/ngbaojia">
</property>
<property name="username" value="root"></property>
<property name="password" value="charmingyb"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/ngbaojia/entity/Customerinfo.hbm.xml</value>
<value>com/ngbaojia/entity/User.hbm.xml</value>
<value>com/ngbaojia/entity/Offerprice.hbm.xml</value>
<value>com/ngbaojia/entity/Enginner.hbm.xml</value>
<value>com/ngbaojia/entity/Material.hbm.xml</value>
<value>com/ngbaojia/entity/Materialcolumn.hbm.xml</value>
<value>com/ngbaojia/entity/Enginnercolumn.hbm.xml</value>
<value>com/ngbaojia/entity/Master.hbm.xml</value>
<value>com/ngbaojia/entity/Deptmenu.hbm.xml</value>
<value>com/ngbaojia/entity/Department.hbm.xml</value>
<value>com/ngbaojia/entity/Menu.hbm.xml</value>
</list>
</property></bean>
<bean id="UserDao" class="com.ngbaojia.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="UserService" class="com.ngbaojia.service.impl.UserServiceImpl">
<property name="userDao" ref="UserDao"></property>
</bean>
<bean id="UserAction" class="com.ngbaojia.action.UserAction">
     <property name="userService" ref="UserService"></property>
</bean>
<bean id="OfferpriceDao" class="com.ngbaojia.dao.impl.OfferpriceDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="OfferpriceService" class="com.ngbaojia.service.impl.OfferpriceServiceImpl">
<property name="offerpriceDao" ref="OfferpriceDao"></property>
</bean>
<bean id="MaterialcolumnDao" class="com.ngbaojia.dao.impl.MaterialcolumnDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="MaterialcolumnService" class="com.ngbaojia.service.impl.MaterialcolumnServiceImpl">
<property name="materialcolumnDao" ref="MaterialcolumnDao"></property>
</bean>
<bean id="MaterialDao" class="com.ngbaojia.dao.impl.MaterialDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="MaterialService" class="com.ngbaojia.service.impl.MaterialServiceImpl">
<property name="materialDao" ref="MaterialDao"></property>
</bean>
<bean id="masterDao" class="com.ngbaojia.dao.impl.MasterDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="MasterService" class="com.ngbaojia.service.impl.MasterServiceImpl">
<property name="masterDao" ref="masterDao"></property>
</bean>
<bean id="MasterAction" class="com.ngbaojia.action.MasterAction">
    <property name="masterService" ref="MasterService"></property>
</bean>
<bean id="EnginnercolumnDao" class="com.ngbaojia.dao.impl.EnginnercolumnDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="EnginnercolumnService" class="com.ngbaojia.service.impl.EnginnercolumnServiceImpl">
<property name="enginnercolumnDao" ref="EnginnercolumnDao"></property>
</bean>
<bean id="EnginnerDao" class="com.ngbaojia.dao.impl.EnginnerDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="EnginnerService" class="com.ngbaojia.service.impl.EnginnerServiceImpl">
<property name="enginnerDao" ref="EnginnerDao"></property>
</bean>
<bean id="CustomerinfoDao" class="com.ngbaojia.dao.impl.CustomerinfoDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="CustomerinfoService" class="com.ngbaojia.service.impl.CustomerinfoServiceImpl">
<property name="customerinfoDao" ref="CustomerinfoDao"></property>
</bean>
<bean id="MenuDao" class="com.ngbaojia.dao.impl.MenuDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="MenuService" class="com.ngbaojia.service.impl.MenuServiceImpl">
<property name="menuDao" ref="MenuDao"></property>
</bean>
<bean id="DepartmentDao" class="com.ngbaojia.dao.impl.DepartmentDaoImpl">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean><bean id="DepartmentService" class="com.ngbaojia.service.impl.DepartmentServiceImpl">
    <property name="departmentDao" ref="DepartmentDao"></property>
</bean>
<bean id="DeptMenuDao" class="com.ngbaojia.dao.impl.DeptMenuDaoImpl">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="DeptMenuService" class="com.ngbaojia.service.impl.DeptMenuServiceImpl">
    <property name="deptMenuDao" ref="DeptMenuDao"></property>
</bean>
</beans>

你这个应该是把spring和hibernate的配置文件合在一起了吧!基本上都差不多的呀!
我习惯把它们配置文件分开管理。
这些也都没能说明问题所在啊??? --------------------编程问答-------------------- 把你的Struts配置文件贴出来看卡 --------------------编程问答-------------------- 你想在dao里面用hibernatetemplate 又没有在dao下面配置 你是如何使用的?在dao下面加上


 <property name="hibernaTetemplate">
            <ref bean="hibernatetemplate" />
        </property>

并且把注释掉的那段打开
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,