leisure

JAVA - exceed,helloworld
随笔 - 50, 文章 - 0, 评论 - 11, 引用 - 0
数据加载中……

2012年7月11日

flash调用javascript

flash.external.ExternalInterface.call("pop")

posted @ 2013-01-11 10:34 leisure 阅读(518) | 评论 (0)编辑 收藏

spring2 JNDI

      <bean id= "myjndi" class= "org.springframework.jndi.JndiObjectFactoryBean" >
             <property name ="jndiName" value= "java:comp/env/jdbc/myjndi" />
      </bean >

posted @ 2013-01-11 10:33 leisure 阅读(508) | 评论 (0)编辑 收藏

两个div在同一行

<style>
.b,.c{float:left; margin-right:10px;}
</style>
<div class="a">
  <div class="b">
      test
  </div>
  <div class="c">
       testc
  </div>
</div>

posted @ 2013-01-11 10:32 leisure 阅读(928) | 评论 (0)编辑 收藏

Javascriptz格式化数字

<script>
    
/*** 格式化数字显示方式
        * 用法
        * formatNumber(12345.999,'#,##0.00');
        * formatNumber(12345.999,'#,##0.##');
        * formatNumber(123,'000000');
        * @param num* @param pattern
    
*/
    
function formatNumber(num,pattern){
        num 
= Number(num);
        
var strarr = num?num.toString().split('.'):['0'];
        
var fmtarr = pattern?pattern.split('.'):[''];
        
var retstr='';    // 整数部分
        var str = strarr[0];
        
var fmt = fmtarr[0];
        
var i = str.length-1;
        
var comma = false;
        
for(var f=fmt.length-1;f>=0;f--){
            
switch(fmt.substr(f,1)) {
                
case '#':
                    
if(i>=0 ) retstr = str.substr(i--,1+ retstr;
                    
break;
                
case '0':
                    
if(i>=0) retstr = str.substr(i--,1+ retstr;else retstr = '0+ retstr;
                    
break;
                
case ',':
                    comma 
= true;
                    retstr
=','+retstr;
                    
break;
            }
        }
        
if(i>=0){
            
if(comma){
                
var l = str.length;
                
for(;i>=0;i--){
                    retstr 
= str.substr(i,1+ retstr;
                    
if(i>0 && ((l-i)%3)==0) retstr = ',' + retstr;
                }
            } 
else 
                retstr 
= str.substr(0,i+1+ retstr;
        }
            retstr 
= retstr+'.';// 处理小数部分
            str=strarr.length>1?strarr[1]:'';
            fmt
=fmtarr.length>1?fmtarr[1]:'';
            i
=0;
            
for(var f=0;f<fmt.length;f++){
                
switch(fmt.substr(f,1)){
                    
case '#':
                        
if(i<str.length) retstr+=str.substr(i++,1);
                        
break;
                    
case '0':
                        
if(i<str.length) retstr+= str.substr(i++,1);
                        
else retstr+='0';
                        
break;
                    }
            } 
            
return retstr.replace(/^,+/,'').replace(/\.$/,'');
    }
    
    document.write(
"formatNumber('','')=" + formatNumber('',''));
    document.write(
"<br/>");
    document.write(
"formatNumber(123456789012.129,null)=" + formatNumber(123456789012.129,null));
    document.write(
"<br/>");
    document.write(
"formatNumber(null,null)=" + formatNumber(null,null));
    document.write(
"<br/>");
    document.write(
"formatNumber(123456789012.129,'#,##0.00')=" + formatNumber(123456789012.129,'#,##0.00'));
    document.write(
"<br/>");
    document.write(
"formatNumber(123456789012.129,'#,##0.##')=" + formatNumber(123456789012.129,'#,##0.##'));
    document.write(
"<br/>");
    document.write(
"formatNumber(123456789012.129,'#0.00')=" + formatNumber(123456789012.129,'#,##0.00'));
    document.write(
"<br/>");
    document.write(
"formatNumber(123456789012.129,'#0.##')=" + formatNumber(123456789012.129,'#,##0.##'));
    document.write(
"<br/>");
    document.write(
"formatNumber(12.129,'0.00')=" + formatNumber(12.129,'0.00'));
    document.write(
"<br/>");
    document.write(
"formatNumber(12.129,'0.##')=" + formatNumber(12.129,'0.##'));
    document.write(
"<br/>");
    document.write(
"formatNumber(12,'00000')=" + formatNumber(12,'00000'));document.write("<br/>");
    document.write(
"formatNumber(12,'#.##')=" + formatNumber(12,'#.##'));
    document.write(
"<br/>");
    document.write(
"formatNumber(12,'#.00')=" + formatNumber(12,'#.00'));
    document.write(
"<br/>");
    document.write(
"formatNumber(1080.0,'#.##')=" + formatNumber(1100.0,'#,###.##'));
    document.write(
"<br/>");
</script>

posted @ 2013-01-11 10:30 leisure 阅读(281) | 评论 (0)编辑 收藏

去掉eclipse的validate

困扰了好几天,与大家共享

1,在project名称上右键选择properties,打开属性窗口,选择左边的validation

2,勾选enable project specific setting;

3,点击Disable all,点击OK关闭窗口

4,在project名称上右键validate

备注:suspend all validators勾选没有效果,另外第4步很重要

posted @ 2013-01-11 10:20 leisure 阅读(7082) | 评论 (0)编辑 收藏

spring method interceptor

spring method interceptor

-author: leisure.xu

首先dao里面有find和save方法,本实例以拦截find方法为主,并改变find的返回值。

package com.leisure;

public class Dao {

     public String find() {

          System. out.println( "dao: find()");

          return "student";

     }

     public void save() {

          System. out.println( "dao: save()");

     }

}

一、新增一个DaoInterceptor,如下

package com.leisure;

import org.aopalliance.intercept.MethodInterceptor;

import org.aopalliance.intercept.MethodInvocation;

/**

 * class description goes here

 * @author leisure.xu

 * @version 1.0.0, 2012 -6 -29

 */

public class DaoInterceptor implements MethodInterceptor {

     @Override

     public Object invoke(MethodInvocation invocation) throws Throwable {

          String methodName = invocation.getMethod().getName();

          if( "find".equals(methodName)) {

               System. out.println( "invocation modify the return result to 'teacher'");

               return "teacher";

          }

          return invocation.proceed();

     } 

}

     DaoInterceptor实现了MethodInterceptor的invoke方法,在这里,MethodInvocation参数可以获取到getArguments等数据,至于能做什么,你懂的。

二、Dao跟DaoInterceptor还是没扯上关系,这时需要修改applicationContext.xml

     原来:

     <bean id = "dao" class= "com.leisure.Dao"/>

修改为:

          <!--

      <bean id=" dao" class="com.leiusre.Dao"/>

     -->

     <bean id ="daoInterceptor" class="com.leisure.DaoInterceptor"/>

     <bean id ="dao" class= "org.springframework.aop.framework.ProxyFactoryBean" >

          <property name ="target">

               <bean class ="com.leisure.Dao" />

          </property >

          <property name ="interceptorNames">

               <list >

                    <value >daoInterceptor </value >

               </list >

          </property >

     </bean >

三、运行看效果!

     ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml" );

     Dao dao = context.getBean(Dao. class);

     System. out.println(dao.find());

     dao.save();

结果:

invocation modify the return result to 'teacher'

teacher

dao: save()

从结果可以看出invocation拦截了find方法,并且修改了其返回结果,而对象的find方法并没有执行到。

该实例引用到的jar包:




posted @ 2012-07-11 09:14 leisure 阅读(992) | 评论 (0)编辑 收藏