2014年3月14日

spring获取webapplicationcontext,applicationcontext几种方法详解

摘要: spring获取webapplicationcontext,applicationcontext几种方法详解方法一:在初始化时保存ApplicationContext对象 代码: ApplicationContext ac = new FileSystemXmlApplicationContext("applicationContext.xml"); ac.getBean("beanId"); 说明:这种方式适用于采用Spring框架的独立应用程序,需要程序通过配置文件手工初始化Spring的情况。方法二:通过Spring提供的工具类获取Applicat 阅读全文

posted @ 2014-03-14 10:20 锟斤拷锟斤拷 阅读(203) 评论(0) 推荐(0)

Java精确测量代码运行时间 代码执行时间 纳秒 nanoTime

摘要: Java精确测量代码运行时间: long startTime = System.nanoTime(); //開始時間 for(int i = 0;i<10000;i++){ ; } long consumingTime = System.nanoTime() - startTime; //消耗時間 System.out.println(consumingTime); System.out.println(consumingTime/1000+"微秒");JDK的解释:public static long nanoTime()Returns the current va 阅读全文

posted @ 2014-03-14 09:54 锟斤拷锟斤拷 阅读(393) 评论(0) 推荐(0)

java中使用二进制进行权限控制

摘要: 基本概念[java] view plaincopyprint?package test; publicclass Rights { publicstaticvoid main(String[] args) { int a=1; // 001 状态a int b=2; // 010 状态b int c=4; // 100 状态c int ab = a | b; // 001 | 010 = 011 初始状态 System.out.println(ab | c); // 011 | 100 = 111 添加c的状态 System.out.println(ab & (~b));... 阅读全文

posted @ 2014-03-14 09:05 锟斤拷锟斤拷 阅读(1498) 评论(0) 推荐(1)

导航