你都继承HibernateDaoSupport 了,直接注入sessionFactory就行了,不用再写
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
解决方案 »
- myeclipse中导入struts2的包后tomcat服务启动错误
- ibatis+mysql 如何查到最新插入的id
- 随机平均分配问题
- 如何才能15天内学完STRUTS SPRING HIBERNATE?
- ------------------------>one2one单向关联,外键为空<------------------------
- 目前 java支持rest风格 使用最广泛的开源框架是什么?
- 请问如何拦截远程通信数据?(HTTP协议的,不考虑安全通道的数据)
- 新手求助,jboss下如何执行servlet?
- [讨论]这样的系统采用J2EE是否恰当。
- springmvc整合freemarker,前端layui表格请求json数据报406异常,请求大佬帮忙解决
- JAVA有关定时任务的操作
- Java调用VC写的Webservice出错(进者有分)
<ref local="hibernateTemplate"/>
</property>
这个也不需要了,都去掉了,试试
<property name="hibernateTemplate">
<ref local="hibernateTemplate"/>
</property>
</bean>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://localhost:3306/htwebsite</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>root</value> </property> </bean>
<!-- hibernate3 session Bean--> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"><!-- 注入数据源 --> <ref local="dataSource" /> </property>
<property name="mappingResources">
<list>
<value>test/Logintable.hbm.xml</value>
</list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean>
<!-- 事务管理 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<bean id="LogintableDao" class="test.LogintableDao">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean name="adduser" class="action.AddUserAction"></bean>
</beans>
<listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
</listener>
似乎默认的是WEB-INF目录
还有
<!-- 事务管理 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
这个你也没挂事务啊,可以看看spring的中文文档找找spring配置文件怎么写吧
还有后台有没有什么错误提示什么的