05 2012 档案

摘要:public class Test { public static void main(String[] args) { MyThread m1 = new MyThread("m1"); MyThread m2 = new MyThread("m2"); m1.start(); m2.start(); } } class MyThread extends Thread { MyThread(String s) { super(s); } public void run() { for(int i = 1; i <= 100; i++) { Sys 阅读全文
posted @ 2012-05-04 23:26 spring3 阅读(215) 评论(0) 推荐(0)
摘要:public class Test { public static void main(String[] args) { MyThread myThread = new MyThread("m1"); myThread.start(); //产生分支,子线程开始执行 try{ myThread.join();//------等待合并myThread子线程,主线程才开始执行 } catch(InterruptedException e) {} for(int i = 1; i <= 10; i++) { System.out.println("I... 阅读全文
posted @ 2012-05-04 23:15 spring3 阅读(252) 评论(0) 推荐(0)
摘要:import java.util.*; public class Test { public static void main(String[] args) { MyThread thread = new MyThread(); thread.start(); try { Thread.sleep(10000);//主线程睡眠 } catch(InterruptedException e) { } thread.interrupt(); //-----------不是最好的方法 //thread.flag = false; ... 阅读全文
posted @ 2012-05-04 23:01 spring3 阅读(294) 评论(0) 推荐(0)
摘要://接口------推荐 public class Test { public static void main(String[] args) { Runner1 r = new Runner1(); //r.run();------->不是多线程,只是方法调用 Thread t = new Thread(r); t.start();//必须调用线程类的start()方法 //也可以这样: //new Thread(new Runner1()).start(); for(int i = 0; i < 100; i++) { ... 阅读全文
posted @ 2012-05-04 22:26 spring3 阅读(1073) 评论(0) 推荐(0)
摘要:一、spring工作原理: 1.spring mvc请所有的请求都提交给DispatcherServlet,它会委托应用系统的其他模块负责负责对请求进行真正的处理工作。2.DispatcherServlet查询一个或多个HandlerMapping,找到处理请求的Controller.3.DispatcherServlet请请求提交到目标Controller4.Controller进行业务逻辑处理后,会返回一个ModelAndView5.Dispathcher查询一个或多个ViewResolver视图解析器,找到ModelAndView对象指定的视图对象6.视图对象负责渲染返回给客户端。 二、 阅读全文
posted @ 2012-05-04 19:33 spring3 阅读(20622) 评论(2) 推荐(1)
摘要:Hibernate工作原理及为什么要用?原理:1. 读取并解析配置文件2. 读取并解析映射信息,创建SessionFactory3. 打开Sesssion4. 创建事务Transation5. 持久化操作6. 提交事务7. 关闭Session8. 关闭SesstionFactory为什么要用:* 对JDBC访问数据库的代码做了封装,大大简化了数据访问层繁琐的重复性代码。* Hibernate是一个基于JDBC的主流持久化框架,是一个优秀的ORM实现。他很大程度的简化DAO层的编码工作* hibernate使用Java反射机制,而不是字节码增强程序来实现透明性。* hibernate的性能非常好 阅读全文
posted @ 2012-05-04 19:30 spring3 阅读(6499) 评论(0) 推荐(1)
摘要:import java.io.*; // transient 关键字 // serializable 接口 // externalizable 接口 public class Test { public static void main(String[] args) throws Exception{ T t = new T(); t.k = 8; FileOutputStream fos = new FileOutputStream("C:/java/testobjectio.txt"); ObjectOutputStream oos = new Obj... 阅读全文
posted @ 2012-05-04 17:31 spring3 阅读(221) 评论(0) 推荐(0)
摘要:关键字: js一、类型转换 1.转换成字串 ECMAScript的Boolean值、数字和字串的原始值的有趣之处在于它们是伪对象,这意味着它们实际上具有属性和方法。 如: Js代码varsColor="blue"; alert(sColor.length);//outputs"4"[js] view plaincopyvarsColor="blue";alert(sColor.length);//outputs"4"总而言之,3种主要的原始值Boolean值、数字和字串都有toString()方法。ECMAScri 阅读全文
posted @ 2012-05-04 13:35 spring3 阅读(1807) 评论(0) 推荐(1)
摘要:Convention Plugin原文:http://cwiki.apache.org/WW/convention-plugin.html翻译:石太祥(ealpha@gmail.comhttp://www.lalfa.com)·1Introduction·2Setup·3Converting a Codebehind based application to Convention·4Hello world·5Code behind hello world·6Results and result codes·7Chaining 阅读全文
posted @ 2012-05-04 12:58 spring3 阅读(2332) 评论(0) 推荐(0)
摘要:1,Get中数据大小被限制:我们都知道很多老式浏览器把URL的字符串个数被限制在255个之内;虽然现在的新版浏览器早就没有这个蛋疼的限制,但是我们可不敢保证所有来站点访问的用户都是使用新版浏览器的。所以当我们需要用户在网页中填写一些信息时,使用Get方式肯定会出问题。相反Post方法中没有这个限制,我们可以传输任意大小的数据。 2,Get中的数据类型不灵活:因为Get是使用url来传输数据的,那么比如空格字符以及类似&这样的字符就不方便传输。我们可以使用发送前编码,以及接受后解码的方法来解决。 3,安全性:在Get中,参数是以名值对的查询字符串挂接在url后缀来传输的,所以这个非常容易 阅读全文
posted @ 2012-05-04 09:52 spring3 阅读(1686) 评论(0) 推荐(0)
摘要:import java.util.*; import java.io.*; //简单的日志功能 public class Test { public static void main(String[] args) { String s = null; BufferedReader br = new BufferedReader ( new InputStreamReader(System.in));//标准输入 try { FileWriter fw = new FileWriter("C:/java/logfile.txt",true)... 阅读全文
posted @ 2012-05-03 22:17 spring3 阅读(436) 评论(0) 推荐(0)
摘要:import java.io.*; public class Test { public static void main(String[] args) { // 字节数组(内存)----<---baos-<---====<==dos==<===程序 ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); try { dos.writeDouble(Math.random()); ... 阅读全文
posted @ 2012-05-03 21:01 spring3 阅读(142) 评论(0) 推荐(0)
摘要:import java.io.*; public class Test { public static void main(String[] args) { try { OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("C:/java/char.txt")); osw.write("microsoftibssunapplehp"); System.out.println(osw.getEncoding());//文本编码 osw.close(); //加了tr... 阅读全文
posted @ 2012-05-03 20:24 spring3 阅读(144) 评论(0) 推荐(0)
摘要:import java.util.Scanner; public class MoFang { public static void main(String[] args) { System.out.println("输入行(列)数:"); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] a = new int[n][n]; int i = 0; int j = n / 2; //算法精要 for (int k = 1; k <= n * n; k++) { ... 阅读全文
posted @ 2012-05-03 19:52 spring3 阅读(222) 评论(0) 推荐(0)
摘要:### 指定加载struts2配置文件管理器,默认为org.apache.struts2.config.DefaultConfiguration### 开发者可以自定义配置文件管理器,该类要实现Configuration接口,可以自动加载struts2配置文件。# struts.configuration=org.apache.struts2.config.DefaultConfiguration### 设置默认的locale和字符编码# struts.locale=en_USstruts.i18n.encoding=UTF-8### 指定struts的工厂类# struts.objectFa 阅读全文
posted @ 2012-05-03 19:42 spring3 阅读(238) 评论(0) 推荐(0)
摘要:package com.svse.upload;import java.io.FileOutputStream;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.ServletInputStream;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;@SuppressW 阅读全文
posted @ 2012-05-03 13:17 spring3 阅读(786) 评论(0) 推荐(0)
摘要:现在使用的版本extjs3.3.1在extjs中window加载的是一个jframe,而iframe中引入了js,在这个时候js不能运行,但是在火狐中是OK的,在IE6.0(开发中一般会使用IE6.0)不可以加载js,这个问题需要你加载完成之后重新reload()一下即可 var myHtml='<iframe id="ifrm008" name="ifrm008" scrolling="auto" frameborder="0" width="100%"height=" 阅读全文
posted @ 2012-05-03 13:06 spring3 阅读(391) 评论(0) 推荐(0)
摘要:import java.io.*; public class Test { public static void main(String[] args) { try { FileInputStream fis = new FileInputStream("C:/java/Test.java"); BufferedInputStream bis = new BufferedInputStream(fis); int c = 0; System.out.println(bis.read()); System.out.println(bis.rea... 阅读全文
posted @ 2012-05-02 16:59 spring3 阅读(362) 评论(0) 推荐(0)
摘要:import java.io.*; public class TestFileReader { public static void main(String[] args) { FileReader fr = null; int c = 0; try { fr = new FileReader("C:/java/Test.java"); while((c = fr.read()) != -1) { System.out.print((char)c); } fr.close(); } catch (FileNotFoundExcepti... 阅读全文
posted @ 2012-05-01 22:18 spring3 阅读(171) 评论(0) 推荐(0)
摘要:import java.io.*; public class Test { public static void main(String[] args) { int b = 0; FileInputStream in = null; try { in = new FileInputStream("C:/java/Test.java"); } catch (FileNotFoundException e) { System.out.println("找不到指定文件"); System.exit(-1); } try { ... 阅读全文
posted @ 2012-05-01 21:37 spring3 阅读(234) 评论(0) 推荐(0)
摘要://TestArsgWords.java import java.util.*; public class TestArgsWords { public static void main(String[] args) { Map<String, Integer> m = new HashMap<String, Integer>(); for(int i = 0; i < args.length; i++) { if(!m.containsKey(args[i])) { m.put(args[i], 1); } else { int fr... 阅读全文
posted @ 2012-05-01 15:06 spring3 阅读(332) 评论(0) 推荐(0)
摘要:import java.util.*; public class TestArgsWords { public static void main(String[] args) { Map m = new HashMap(); for(int i = 0; i < args.length; i++) { int freq = ((Integer) m.get(args[i]) == null ? 0 : (Integer) m.get(args[i])); m.put(args[i], (freq == 0 ? 1 : freq + 1)); } ... 阅读全文
posted @ 2012-05-01 14:41 spring3 阅读(253) 评论(0) 推荐(0)
摘要:import java.util.*; public class Test { public static void main(String[] args) { Map m1 = new HashMap(); Map m2 = new HashMap(); m1.put("one", 1); //m1.put("one",new Integer(1)); m1.put("two", 2); //m1.put("two",new Integer(2)); m1.put("three", 3); / 阅读全文
posted @ 2012-05-01 14:21 spring3 阅读(219) 评论(0) 推荐(0)
摘要:import java.lang.Comparable; import java.util.List; import java.util.LinkedList; import java.util.Collections; public class TestCompareTo { public static void main(String[] args) { List l1 = new LinkedList(); l1.add(new Name("Karl", "M")); l1.add(new Name("Stever", &quo 阅读全文
posted @ 2012-05-01 13:40 spring3 阅读(216) 评论(0) 推荐(0)
摘要:import java.util.*; public class TestCollection { public static void main(String[] args) { List<String> l1 = new LinkedList<String>(); for(int i = 0; i <= 5; i++) { l1.add("a" + i); } System.out.println(l1); l1.add(3, "a100"); System.out.println(l1); l1.set(6, &quo 阅读全文
posted @ 2012-05-01 13:11 spring3 阅读(397) 评论(0) 推荐(0)
摘要:import java.util.ArrayList; import java.util.Collection; public class Test { public static void main(String[] args) { int [] arr = {1, 2, 3, 4, 5}; for(int i : arr) { System.out.print(i + " "); } System.out.println(); Collection<String> c = new ArrayList<String>(); c.add(new St 阅读全文
posted @ 2012-05-01 10:36 spring3 阅读(255) 评论(0) 推荐(0)
摘要:import java.util.Collection; import java.util.HashSet; import java.util.Iterator; public class Test { public static void main(String[] args) { Collection<Name> c = new HashSet<Name>(); c.add(new Name("f1", "l1")); c.add(new Name("f2", "l2")); c.add 阅读全文
posted @ 2012-05-01 10:27 spring3 阅读(191) 评论(0) 推荐(0)