• 每日记载内容总结20


    1.mysq问题(转)

     严重: The web application [/codeMarket] created a ThreadLocal with key of type [null] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@e1666]) and
     a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@e0ada6]) but failed to remove it when the web application was stopped.
     This is very likely to create a memory leak.
    2012-2-9 17:43:12 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
    严重: The web application [/codeMarket] created a ThreadLocal with key of type [null]
    (value [com.opensymphony.xwork2.inject.ContainerImpl$10@a8a314]) and a value of type [java.lang.Object[]]
    (value [[Ljava.lang.Object;@16ab2e8]) but failed to remove it when the web application was stopped.
    This is very likely to create a memory leak.
    第一个异常  严重: The web application [/codeMarket] registered the JBDC driver [oracle.jdbc.OracleDriver]
    but failed to unregister it when the web application was stopped.
    To prevent a memory leak, the JDBC Driver has been forcibly unregistered
    程序运行了jdbc驱动,可是当程序停止时,无法注销这个驱动,tomcat为了防止内存溢出,就给强制注销了
    由于JDBC连接池用的是dbcp,dbcp1.3/1.4连接池没有自动的去回收空闲连接的功能,在1.3.1、1.4.1版本做了修复
    (可以替换成新版本试试,亦可以按以下方案重写,也可以考虑使用c3p0,它有自动回收空闲连接功能)

    解决方法:重写了org.apache.commons.dbcp.BasicDataSource  的 close()方法:
    package org.company.util;

    import java.sql.DriverManager;
    import java.sql.SQLException;

    import org.apache.commons.dbcp.BasicDataSource;

    public class XBasicDataSource extends BasicDataSource{
     @Override
     public synchronized void close() throws SQLException{
    //  System.out.println("......输出数据源Driver的url:"+DriverManager.getDriver(url));
      DriverManager.deregisterDriver(DriverManager.getDriver(url));
      super.close();
     }
    }

    在dbcp数据源中的配置:

    <bean id="myDataSource"
      class="org.company.util.XBasicDataSource" destroy-method="close">
      <property name="driverClassName"
       value="oracle.jdbc.driver.OracleDriver">
      </property>
      <property name="url"
       value="jdbc:oracle:thin:@XX.XXX.XX.X:1521:ccdb">
      </property>
      <property name="username" value="codemanage"></property>
      <property name="password" value="codemanage"></property>
      <property name="maxActive" value="10"></property>
      <property name="initialSize" value="5"></property>
      <property name="removeAbandoned" value="true"></property>
      <property name="removeAbandonedTimeout" value="3600"></property>
     </bean>
     即可解决问题

    第二个问题

    再重新加载的时候发现还有:

    严重: The web application [/codeMarket] registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped.
    To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
    2012-2-9 17:43:12 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

    检查了一下jar包  发现多了一个mysql-connector-java-bin.jar  因为我用的是oracle 但是把mysql和oracle的jar包都加进去了 删掉即可 

    2.js实现点击页面除了某位置的其他位置而触发操作:(就本例而言:该位置id为selectCategory 操作的位置class为search_drop)

    if(document.addEventListener){
            document.addEventListener("click", function(e) {
            var allClick = document.getElementById("selectCategory");
            var target = e.target || e.srcElement;
            
            while (target != document && target != allClick) {
                target = target.parentNode;
            }
            if (target == document) {
                $(".search_drop").hide();
            }
        
            }, false);
        }else if(document.attachEvent){
            document.attachEvent("onclick",function(e) {
                var allClick = document.getElementById("selectCategory");
                var target = e.target || e.srcElement;
                while (target != document && target != allClick) {
                    target = target.parentNode;
                }
                if (target == document) {
                    $(".search_drop").hide();
                }
        
                });

    亲测兼容ie6到ie10 , firefox ,chrome

    3.toggleClass :为元素添加class 以及移除class
    <div class="tumble">Some text.</div>  ---->  $('div.tumble').toggleClass('bounce') ----->
    <div class="tumble bounce">Some text.</div> ---->  $('div.tumble').toggleClass('bounce') ----->
    <div class="tumble">Some text.</div>

    4.siblings: $(A).siblings(B) 筛选出与A同辈的满足B选择器的元素,
    若B为空,而且A可以选出准确的元素,该表达式得到与A同辈的所有元素但不包括A
    如果A未选择出一个准确的元素,则包含所有元素
    例如 :<li>2</li><li class="second-item">2</li><li>3</li><li>4</li><li>5</li>
    $("li").siblings().  ……  该表达式得到与A同辈的所有元素而且包括A,即所有li
    $("li.second-item").siblings(). 该表达式得到与A同辈的所有元素但不包括A

    5.模拟qq的好友分组功能:

    <html>
        
        <head>
        <style type="text/css" >
        .subSer{
            color:red;
            width:100px;
        }
        </style>
        <script type="text/javascript" src="jquery.min.js"></script>
        <script type="text/javascript">
            $(function(){
                $(".subSer").toggle(function(){        
                    $(this).next("li").hide();            
                },function(){
                    $(this).next("li").show();
                }
                );        
            });
        </script>
        </head>
        <body>
            <div id="qq">
                <ul>
                    <li class="subSer">My Friend</li>
                    <li class="hujin" style="list-style-type:none">DA<br>ER<br>TY<br>CD<br></li>
                    <li class="subSer">Classmates</li>
                    <li class="hujin" style="list-style-type:none">DA<br>ER<br></li>
                    <li class="subSer">Strangers</li>
                    <li class="hujin" style="list-style-type:none">TY<br>CD<br></li>
                </ul>
            </div>
        </body>
    </html>
  • 相关阅读:
    python3操作sqlserver,查询数据统计导出csv
    scrapy入门二(分页抓取文章入库)
    stm32 调试时卡在LDR R0, =SystemInit
    STM32F407 串口通信实验 第26节 个人笔记
    STM32F407 串口通信:分类&常见接口 个人笔记
    STM32F407 IO引脚复用器和映射 个人笔记
    STM32F407 按键输入实验 库函数版 个人笔记
    STM32F407 GPIO 库函数编程套路(led与beep总结) 个人笔记
    STM32F407 跑马灯 寄存器版 个人笔记
    STM32F407 跑马灯 库函数版 个人笔记
  • 原文地址:https://www.cnblogs.com/cuiyf/p/3281561.html
Copyright © 2020-2023  润新知