第一次配置opensessioninview。。写下来。。
2010-08-11 13:39
260 查看
首先web.xml加入
我的applicationContext.xml文件。。
查询什么的用getHibernateTemplate().find。。
好像在struts配置文件用plug-in加载,初始化spring的是用不了OpenSessionInView的。我一直没有时间去研究怎么解决这个,我就直接在web.xml里加载的spring配置文件。
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> </filter> <filter-mapping> <filter-name>OpenSessionInViewFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <servlet>
我的applicationContext.xml文件。。
<!-- Impl注入 --> <bean id="HelloDAOProxy" parent="Proxy"> <property name="target"> <ref bean="HelloDAOImpl" /> </property> </bean> <bean name="WarmingDAOImpl" class="cn.com.xxx.daoimpl.HelloDAOImpl" singleton="false"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="Proxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true" lazy-init="true"> <property name="transactionManager"> <ref bean="myTransactionManager" /> </property> <property name="transactionAttributes"> <props> <prop key="Dept*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="add*">PROPAGATION_REQUIRED</prop> <prop key="del*">PROPAGATION_REQUIRED</prop> <prop key="user*">PROPAGATION_REQUIRED</prop> <prop key="look*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="do*">PROPAGATION_REQUIRED</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="select*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> <!-- 事务管理者数据库 --> <bean id="myTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="mappingResources"> <list> <value>cn/com/xxx/entity/Hello.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="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value> jdbc:mysql://localhost:3306/xxxx?useUnicode=true&characterEncoding=utf-8 </value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>123456</value> </property> </bean>
查询什么的用getHibernateTemplate().find。。
好像在struts配置文件用plug-in加载,初始化spring的是用不了OpenSessionInView的。我一直没有时间去研究怎么解决这个,我就直接在web.xml里加载的spring配置文件。
相关文章推荐
- OpenSessionInViewFilter 的配置及作用
- Spring 4.16: OpenSessionInViewFilter 的配置及作用
- Spring——OpenSessionInViewFilter 的配置及作用
- spring管理hibernate延迟加载配置(openSessionInView)
- OpenSessionInViewFilter 的配置及替代方案
- [转]Spring配置之OpenSessionInViewFilter
- OpenSessionInViewFilter 的配置及替代方案
- OpenSessionInViewFilter作用及配置
- OpenSessionInViewFilter配置
- OpenSessionInViewFilter作用及配置-懒加载
- OpenSessionInViewFilter 的配置及作用
- Spring MVC如何配置OpenSessionInViewInterceptor并结合Hibernate使用
- OpenSessionInViewFilter在web.xml中的配置
- 关于SpringOpenSessionInViewFilter的配置及处理方案
- OpenSessionInViewFilter 的配置及作用
- Spring配置之OpenSessionInViewFilter
- OpenSessionInViewFilter 的配置及作用
- OpenSessionInViewFilter作用及配置
- OpenSessionInViewFilter 的配置
- OpenSessionInViewFilter 的配置及替代方案