zoukankan      html  css  js  c++  java
  • SSH中懒加载异常的解决办法

    web.xml 的配置文件

        <!-- 配置Spring解决懒加载问题的过滤器 -->
        <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>*.action</url-pattern>
        </filter-mapping>
      
        <!-- 配置Struts2的主过滤器 -->
        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>

    注意  :   一定要配置在struts过滤器的上面, 否则不起作用

    使用了OpenSessionInView模式可能造成内存和数据库连接问题
    由于使用了OpenSessionInView模式,Session的生命周期变长。虽然解决了 Lazy Load的问题,但是带来的问题就是Hibernate的一级缓存,也就是Session级别的缓存的生命周期会变得非常长,如果在Service层做大批量的数据操作时,其实这些数据会在缓存中保留一份,这是非常耗费内存的。还有一个数据库连接的问题,存在的原因在于由于数据库的 Connection是和Session绑在一起的,所以,Connection也会得不到及时的释放。因而当系统出现业务非常繁忙,而计算量又非常大的时候,数据连接池的连接数会不够

  • 相关阅读:
    Ansible
    Ansible
    MySQL
    JS计算时间差(天,时,分钟,秒)
    cookie,localStorage,sessionStorage的区别
    css布局 -双飞翼布局&圣杯布局
    Python批量爬取网站图片
    vue-cli3中引入图片的几种方式和注意事项
    git常用命令
    vue-cli3的打包并在本地查看
  • 原文地址:https://www.cnblogs.com/lnzr/p/4196386.html
Copyright © 2011-2022 走看看