如果在spring中使用hibernate就得使用HibernateTemplate基类
HibernateTemplate操作数据库类
要在spring要在ApplicationContext.xml中配置使其生效
方法为<bean id="" class=".">
<property name="sessionfactory">
<value>sessionfactory</value>
</property>
</bean>
通过sessionfactory为bean注入属性
只有三者(struts2表单标筌,action动作类,数据库实体类;dao操作数据库类HibernateTemplate;再加上spring为数据源,sessionfactory,bean类提供配置)完美搭配才能构筑完美的系统。