1。applicationContext.xml 配置
2。web.xml修改
- <filter>
- <filter-name>hibernateOpenSessionInViewFilterContent</filter-name>
- <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
- <init-param>
- <param-name>excludeSuffixs</param-name>
- <param-value>js,css,jpg,gif</param-value>
- </init-param>
- <init-param>
- <param-name>sessionFactoryBeanName</param-name>
- <param-value>sessionFactoryContent</param-value>
- </init-param>
- </filter>
- <filter>
- <filter-name>hibernateOpenSessionInViewFilterIndex</filter-name>
- <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
- <init-param>
- <param-name>excludeSuffixs</param-name>
- <param-value>js,css,jpg,gif</param-value>
- </init-param>
- <init-param>
- <param-name>sessionFactoryBeanName</param-name>
- <param-value>sessionFactoryIndex</param-value>
- </init-param>
- </filter>
-
- <filter-mapping>
- <filter-name>hibernateOpenSessionInViewFilterContent</filter-name>
- <url-pattern>
3。Dao代码中sessionFactory选择
- @Repository
- public class BrandDao extends HibernateDao<Brand,Long>{
- @Override
- @Resource(name = "sessionFactoryContent")
- public void setSessionFactory(SessionFactory sessionFactory) {
- super.setSessionFactory(sessionFactory);
- }
阅读(2715) | 评论(1) | 转发(0) |