Struts2 Hibernate中关闭Session的filter问题

来源:百度文库 编辑:神马文学网 时间:2024/07/02 16:55:35
用Struts2+Hibernate开发Web程序
发现网站老是一动不动,在DAO中用  Statistics stats = HibernateUtil.getSessionFactory().getStatistics();
查看了统计结果,发现打开50个Session只有20个关闭了.
看结构也没有什么问题,我使用两个ThreadLocal 存放Session 和Transaction,再用一个Filter去关闭,各个配置表面上也是没有问题,可是做测试的时候才发现关闭Session的Filter根本就是没有运行,或是有时运行,有时不运行,
仔细想了想,调整了一下sessionclosefilter和Struts2的filter的顺序如下,终于可以关闭了

HibernateSessionCloseFiler
com.hitecin.struts2.filter.HibernateSessionClose


struts-cleanup
org.apache.struts2.dispatcher.ActionContextCleanUp


struts2
org.apache.struts2.dispatcher.FilterDispatcher


HibernateSessionCloseFiler
/*


struts-cleanup
/*


struts2
/*