尝试Spring配置Open Session in View, 但是还是报no session or session was closed,可能会是什么原因?配置Open Session in View有哪些注意事项?谢谢!
web.xml配置片段
<filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> <init-param> <param-name>sessionFactoryBeanName</param-name> <param-value>hibernateSessionFactory</param-value> </init-param> <init-param> <param-name>singleSession</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>OpenSessionInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
Spring hibernate配置片段:
<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml" /> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="hibernateSessionFactory" /> </property> </bean> <aop:config> <aop:advisor pointcut="execution(* *..PersonDAOHibImpl.*(..))" advice-ref="txAdvice" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="insert*" rollback-for="java.sql.SQLException" /> <tx:method name="update*" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice>