自由飞翔

我在仰望,java之上

统计

留言簿(2)

我关注的blog

阅读排行榜

评论排行榜

2012年3月6日 #

编码至高法则-高内聚低耦合

     摘要: 此法则适合所有语言,咱们以JavaScript和Java两个角度分析一下这个东东。 一、javascript 有这样的一个页面,js、css代码都写在html页面中。 例如:gnj.html v1版本Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-...  阅读全文

posted @ 2019-09-11 15:59 GavinMiao 阅读(204) | 评论 (0)编辑 收藏

Jgoodies FormLayout 小结


一、列与行的参数都由三个部分组成:对齐方式、固定尺寸、调整方式。
1.对齐方式:
1)列对齐有left, center, right, fill.默认fill
2)行对齐有:top, center, bottom, fill. 其中fill表示填充至整个区域。默认center。
2.固定尺寸:
pref表示preferred size,适当大小,即首选尺寸大小。
min表示minimum size,
dlu 表示dialog units,
px, pt, in, mm, cm)分别表示Pixel, Points, Inches, Millimeter, Centimeter。
3. 调整方式:
二、CellConstraints:
cc.xywh(3, 1, 3, 1):表示3列,1行,colspan=3,rowspan=1
三、FormLayout:
  1.FormLayout layout = new FormLayout(
   new ColumnSpec[]{
     FormSpecs.DEFAULT_COLSPEC,
     FormSpecs.GLUE_COLSPEC,
     FormSpecs.DEFAULT_COLSPEC,
     FormSpecs.GLUE_COLSPEC,
     FormSpecs.DEFAULT_COLSPEC,
     FormSpecs.GLUE_COLSPEC},
   new RowSpec[]{
     FormSpecs.DEFAULT_ROWSPEC,
     FormSpecs.GLUE_ROWSPEC,
     FormSpecs.DEFAULT_ROWSPEC,
     FormSpecs.GLUE_ROWSPEC,
     FormSpecs.DEFAULT_ROWSPEC,
     FormSpecs.GLUE_ROWSPEC
   }
  );
2.

FormLayout layout = new FormLayout( 
        "right:pref, 6dlu, 50dlu, 4dlu, center:50dlu", // columns
        "pref, 3dlu, pref, 3dlu, pref"); // rows   





参考文章:
http://hi.baidu.com/lijunwyf/item/a18d95f719ff01da6225d26f

posted @ 2012-09-29 11:29 GavinMiao 阅读(1305) | 评论 (0)编辑 收藏

Vector浅见

例子:
import java.util.*;
public class TestVector{
 public static void main(String[] args){
  Vector v = new Vector();
  v.add(null);
  v.add(new Integer(1));
  v.add("123");
  
  for(Enumeration e = v.elements();e.hasMoreElements();){
   System.out.println(e.nextElement());
  }
  v.insertElementAt("insert",2);
  v.setElementAt("insert",0);
  
  for(Enumeration e = v.elements();e.hasMoreElements();){
   System.out.println(e.nextElement());
  }
  
 }
}

结果:
null
1
123

insert
1
insert
123
 
结论:
vector中可以放入null;
vector可以放入不同类型的对象;
vector是同步的容量自增长的向量;

posted @ 2012-09-24 08:49 GavinMiao 阅读(293) | 评论 (0)编辑 收藏

火车票订票好办法

一、前提须知:
1.北京铁路局:
直属站15个:北京站北京西站天津站天津西站丰台站丰台西站南仓站塘沽站唐山站石家庄站石家庄南站、邯郸站、阳泉站、北京南站、天津西站。
2.郑州铁路局:
直属车站11个:郑州站、郑州北站、郑州东站、洛阳站、新乡站、开封站、商丘站、月山站、长治北站、长治站。
二、
北京电话订票窍门:1、座机打!;2.用手机加区号打!北京铁路局管内,如唐山区号:打0315-95105105,手机打95105105的有效区号:河北省邯郸0310石家庄0311保定0312张家口0313承德0314唐山0315廊坊0316沧州0317衡水0318邢台0319秦皇岛0335山东德州0534山西阳泉0353天津022。订好之后可以在北京取票!!

posted @ 2012-09-18 07:55 GavinMiao 阅读(353) | 评论 (0)编辑 收藏

异常积累:org.hibernate.StaleStateException

ERROR - Exception executing batch: 
org.hibernate.StaleStateException: Batch update returned unexpected row count fr
om update [0]; actual row count: 0; expected: 1

ERROR - Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row count fr
om update [0]; actual row count: 0; expected: 1


不注意的话,还真的有点无所适从,Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
这个异常是由于主键设置为自增长,而在我们插入记录的时候设置了ID的值导致的。看下我的Hibernate映射文件中ID的定义:

参考文章:http://hi.baidu.com/shirdrn/blog/item/adec1e82d067ddb86c81191c.html

posted @ 2012-04-18 15:33 GavinMiao 阅读(10557) | 评论 (0)编辑 收藏

java.lang.IllegalStateException: Cannot forward after response has been committed

现象:
页面报500.
原因:
在request.getRequestDispatcher("/success.html").forward(request, response);
后面还有未执行的代码,但是已经提交了响应。

posted @ 2012-04-14 09:08 GavinMiao 阅读(465) | 评论 (0)编辑 收藏

UML初接触

1.UML:unified modeling Language(统一建模语言)
2.草图与蓝图:
前者指:手工绘制的、规范度较低的UML模型;
后者指:case工具绘制的正式的、规范的UML模型;
3.不同可视性的符号:
“+”:public   “#”:protected  “-”:private  “~”:package
4.UML主要包含三种图:静态图、动态图、物理图
5.关联关系:用来表示一个对象持有另外一个对象的引用,或是调用另外一个对象的方法
6.类图:


7.类图之间的关联:
—▷▷  —>持有

posted @ 2012-04-13 11:34 GavinMiao 阅读(301) | 评论 (0)编辑 收藏

面试题(互联网网上商城行业)

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-04-12 22:39 GavinMiao 阅读(106) | 评论 (0)编辑 收藏

不用临时变量交换两个数

方法1:
a=a^b;
b=a^b;
a=a^b;
方法2:
a=a+b;
b=a-b;
a=a-b;

posted @ 2012-04-12 11:27 GavinMiao 阅读(394) | 评论 (0)编辑 收藏

易宝支付面试题(根据网上总结)

1.public class TestKnowleage5 {
public static void main(String[] args){
String strValue = "ABCDEFG";
strValue.substring(3);
System.out.println("result1"+strValue);
strValue.concat("123");
System.out.println("result2"+strValue);
String value = new String("ABCDEFG");
System.out.println(strValue==value);
}
}

运行结果:
result1ABCDEFG
result2ABCDEFG
false
2.public class Test{
    public static void main(String[] args){
         int x = 100;
int y = 200;
if(x == y)
System.out.println("not equal");
else
System.out.println("equal");
    }
}

运行结果:
equal

3.public class TestKnowleage5 {
public static void main(String[] args){
try{
new TestKnowleage5().methodA(5);
}catch(IOException e){
System.out.println("caught IOException");
}catch(Exception e){
System.out.println("caught Exception");
}finally{
System.out.println("no Exception");
}
}
public void methodA(int i) throws IOException{
if(i%2 != 0){
throw new IOException("methodA IOException");
}
}
}

运行结果:
caught IOException
no Exception

4.public class TestKnowleage5 {
static boolean isTrue(){
System.out.println("isTrue");
return true;
}
static boolean isFalse(){
System.out.println("isFalse");
return false;
}
public static void main(String[] args){
if(isTrue() || isFalse()){
System.out.println("|| operate return true");
}
if(isFalse() & isTrue()){
System.out.println("& operate return true");
}
}
}

运行结果:
isTrue
|| operate return true
isFalse
isTrue

5.public class TestKnowleage5{
public static void main(String args[]){
MyThread t = new MyThread();
t.run();
t.start();
System.out.println("A");
}
}
class MyThread extends Thread{
public void run(){
try{
Thread.currentThread().sleep(3000);
}catch(InterruptedException e){
}
System.out.println("B");
}
}
运行结果:
BBA或
BAB
6.class A{
void fun1(){
System.out.println(fun2());
}
int fun2(){
return 123;
}
}
public class TestKnowleage5  extends A{
int fun2(){
return 456;
}
public static void main(String[] args){
A a;
TestKnowleage5 b = new TestKnowleage5();
b.fun1();
a = b;
a.fun1();
}
}

运行结果:
456
456
7.class A{
int val;
public int getVal() {
return val;
}
public void setVal(int val) {
this.val = val;
}
}
public class TestKnowleage5{
public static void main(String[] args){
A data = new A();
ArrayList list = new ArrayList();
for(int i=100;i<103;i++){
data.setVal(i);
list.add(data);
}
int j = 0;
while(j<list.size()){
A tmp = (A)list.get(j);
System.out.println("list("+j+")="+tmp.getVal());
j++;
}
}
}

运行结果:
list(0)=102
list(1)=102
list(2)=102

8.hibernate导入大量数据时,为了避免内存中产生大量对象,在编码时注意什么,如何去除?

9.视图与表的区别
10.触发器有哪几种类型
11.
事务操作有那几个步骤
12.写出对应正则表达式:
1)1-6位字母或数字;
[a-zA-Z0-9]{1,6}
2)手机号(只能是139或159开头,11位数字)
1[35][9][0-9]{8}
13.字符串反转:new StringBuilder(str).reverse().toString();
14.写程序:1+2²+3²+...+n²
int func(int n){
    return n==1?1:func(n-1)+n*n
}

15.写一个延迟加载的单例模式:
public class SingleTon{
    private static  SingleTon  instance = null;
    private SingleTon(){}
    public static SingleTon getInstance(){
        if(instance == null){
                synchronized(""){
                    if(instance == null){return new SingleTon();}
                }
        }
        return instance;
    }
}

16.
JSP的9种内置对象:
request:
HttpServletRequest类的实例,
客户端的请求信息被封装在request对象中
response:
HttpServletResponse类的实例,
response对象包含了响应客户请求的有关信息,但在JSP中很少直接用到它。
out:
out对象是JspWriter类的实例,是向客户端输出内容常用的对象
session:
session对象指的是客户端与服务器的一次会话,从客户端连到服务器的一个WebApplication开始,直到客户端与服务器断开连接为止。它是HttpSession类的实例
page:
page对象就是指向当前JSP页面本身,有点象类中的this指针,它是java.lang.Object类的实例
application:
ServletContext类的实例,
application对象实现了用户间数据的共享,可存放全局变量。它开始于服务器的启动,直到服务器的关闭
exception:
exception对象是一个例外对象,当一个页面在运行过程中发生了例外,就产生这个对象。如果一个JSP页面要应用此对象,就必须把isErrorPage设为true,否则无法编译。他实际上是java.lang.Throwable的对象
pageContext:
pageContext对象提供了对JSP页面内所有的对象及名字空间的访问,也就是说他可以访问到本页所在的SESSION,也可以取本页面所在的application的某一属性值,他相当于页面中所有功能的集大成者,它的本类名也叫pageContext
config:
config对象是在一个Servlet初始化时,JSP引擎向它传递信息用的,此信息包括Servlet初始化时所要用到的参数(通过属性名和属性值构成)以及服务器的有关信息(通过传递一个ServletContext对象)
17.session和cookie的区别?
18.JDBC的操作步骤?

posted @ 2012-04-11 11:32 GavinMiao 阅读(1523) | 评论 (0)编辑 收藏

面试题(移动通信方面)

1.方法重载与多态,简述;
2.什么是设计模式?使用过哪些?
3.列出熟悉的java开源项目及简述;
4.一组radio,用alert弹出当前所选的是第几个radio?用原生javascript;
5.function showme(){
Book.prototype.abc = function(){
alert('456');
}
var abook = new Book(1,2);
Book.abc = function(){
alert('123');
}
abook.abc();
Book.abc();
abc();//此方法调用浏览器会报错,未定义
}
function Book(a,b){
this.a = a;
this.b = b;
Book.abc = function(){
alert('def');
}
this.abc = function(){
alert('xyz');
}
abc = function(){
alert('@@@@@@');
}
var abc = function(){
alert('$$$$$$');
}
}

点击按钮调用showme(),页面显示结果为:
第一个弹出框:xyz
第二个弹出框:123

6.线程的四种状态?
7.ext有哪些组件?ext如何与后台交互?
8.HashMap放入、查找、删除,将所有value放入一个数组,得到map中所有内容;List添加、查找、删除;
9.List<Student> student(name,age) 比较oldList<Student>和newList<student>,按名字比较,获得新增的、修改的、删除学生列表;
10.使用过哪些xml技术?怎么实现的?
11.java异常:throws、throw、try、catch、finally,举例,如何处理异常
12.字符串反转:
public class TestKnowleage5 {
public static void main(String[] args){
System.out.println(reverse("abc"));
System.out.println(reverse2("abc"));
System.out.println(reverse3("abc"));
}
public static String reverse(String str){
return new StringBuffer(str).reverse().toString();
}
public static String reverse2(String str){
char[] chs = str.toCharArray();
char[] re = new char[chs.length];
for(int i = 0 ; i<chs.length;i++){
re[i] = chs[chs.length - i - 1]; 
}
return new String(re);
}
public static String reverse3(String str){
char[] chs = str.toCharArray();
String re = ""; 
for(int i = 0;i<chs.length;i++){
re += chs[chs.length - 1 -i];
}
return re;
}
}

posted @ 2012-04-10 22:39 GavinMiao 阅读(513) | 评论 (0)编辑 收藏

面试题(ERP行业)

//此句,编译无法通过,Cannot make a static reference to the non-static field b
1.arrayList、linkedList、vector的区别
2.
写几种J2EE规范并简要描述
3.什么是设计模式?用过哪些设计模式?
4.OO的四大特性是哪些?并简要描述
5.方法重载、多态概念及简要描述;
6.sql常用的优化方法有哪些?
7.sleep()与wait()的区别?
8.
public class TestException {
public static void main(String[] args) {
int i = 1;
switch(i){
case 0:
System.out.println(0);
break;
case 1:
System.out.println(1);
default:
System.out.println(4);
case 2:
System.out.println(2);
case 3:
System.out.println(3);
}
}
}
运行结果:
1
4
2
3
9.HashTable和HashMap的区别
10.怎样理解mvc模式?
11.抽象类、接口的区别?
12.智力题:
有1-7号,7块地,S、U、V、W、X 5个遗产继承者,
S若继承2号,不能继承3号;
3号和4号不能同时继承;
S若继承一块或多块地,则U不能继承
1块地不能被2人合分;

问:若S继承2号地,剩余3个人中,不能同时哪2块地?
A:1和6 B:1和7 c:3和7 d:1和5 e:1和3
13.
public class TestKnowleage5 {
static int a;
int b,c=0;
public static void main(String[] args){
a++;
b++;//此句,编译无法通过,Cannot make a static reference to the non-static field b
c++; //此句,编译无法通过,cannot make a static reference to the non-static field c
}
}


参考文章:

posted @ 2012-04-10 21:59 GavinMiao 阅读(496) | 评论 (0)编辑 收藏

用友面试题(参考网上总结而出)

1,有三个jsp页面:a.jsp b.jsp c.jsp,流程是a.jsp--> b.jsp--> c.jsp,其中a.jsp提交的数据要在c.jsp中访问,用最简单的办法怎么做?不用session。
在b.jsp中放N个hidden隐藏域保存a.jsp中的数据,一起提交到c.jsp,在c.jsp中取出。2.sql server支持集群么?
支持,不过属于热备份类型,不能做负载均衡。不过符合你的条件
首先系统做集群,数据库文件放到磁盘阵列里,双机或多机共同访问磁盘阵列,就可以了,可以集群后做负载均衡;
3.HashTable与HashMap的区别:
1)HashMap非线程安全,HashTable线程安全;
2)HashMap可放一条key为空的记录,任意记录的value可为空,hashTable不可以;
3)hashMap去掉了contains方法,增加了containsKey和containsValue方法;
4.如何理解mvc模式:
mvc是sun提出的model2开发模式,将控制、视图、模型进行了分离;提高了可维护性、扩展性、可移植性、组件的可复用性;
5.SingleTon:
6.对象序列化的含义:
java序列化技术可以使你将一个对象的状态写入一个byte流里,并且可以从其它地方把该byte流里的数据读出来,重新构造一个相同的对象。
这种机制允许你将对象通过网络传播,并且随时可以把对象持久化到数据库、文件等系统里,java的序列化技术是RMI、EJB等技术的基础;
实现方法:implements Serializable标记为可序列化,然后用ObjectOutputStream和ObjectInputStream读写;
7.数据库中的锁包含哪些?
排它锁和共享锁
8.jsp和servlet的区别:
1)简单来说:jsp就是含有java代码的html,servlet就是含有html的java代码;
2)jsp最终被解释成servlet,编译再执行,jsp不过是servlet的另一种编写形式;
3)jsp擅长表示,servlet擅长数据处理,在mvc中jsp处于视图层,servlet处于控制层;
9.oracle在数据库中的交集怎么表示:
1)用intersect操作符 2)用in 语句
9.JNDI、JMS、JTA、RMI:

JNDI:java naming and directory interface java命名目录接口
JMS:java messing service java消息服务
JTA:java transaction api java事务api
RMI:
Remote Method Invocation 远程方法调用

10.事务:

1)ACID属性:
A:atomic 原子性
C:consistent 一致性
I:isolation 隔离性
D:duration 持久性
2)概念:事务就是一系列操作,它们完成一项任务。只要这些操作里有一项没成功,事务就操作失败,发生回滚事件。即撤销前面的操作,这样可以保证数据的一致性。而且可以把操作放在缓存里,等所有操作都成功就提交数据库,这样保证费时的操作都是有效操作。
3)隔离级别 4)传播行为
参考文档:http://wenku.baidu.com/view/56a532eb856a561252d36f81.html

posted @ 2012-04-09 11:32 GavinMiao 阅读(1047) | 评论 (0)编辑 收藏

面试题(某呼叫中心)

1.String b = new String("1"+"2"); -->4个
2.Customer(id,name,phone,country);每个客户均有地区(country)属性,每个地区可有1或多个客户,查询拥有超过10名客户的地区的列表;
3.public interface TreeNode{
    String getName();
    List getChildren();
}
 写一个print()方法,打印各级节点名称.

4.String与StringBuffer的区别?
String
5.ajax名词解释,它的核心价值及原理;
6.事务的概念及名词解释;
7.数据库表之间有几种关系,并举例;
8.Filter的原理,常见用例;
9.视图与表的区别?触发器类型有哪些类型?
10.建表及各种约束;
11.hibernate导入大量数据时,为了避免内存中产生大量对象,在编码时注意什么,如何去除?

posted @ 2012-04-07 00:14 GavinMiao 阅读(734) | 评论 (0)编辑 收藏

String面试题

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-04-06 18:26 GavinMiao 阅读(75) | 评论 (0)编辑 收藏

面试题(通信行业公司)

一、unix:
1.ps -ef|grep tomcat
2.mkdir dir
3.打tar包:tar -cvf XXX.tar XXX
4.解压tar包:tar -xvf XXX.tar
二、java
1.HashMap和HashTable的区别:
HashMap不是线程安全的,
HashTable是线程安全的
HashTable不允许null值(key和value都不可以),HashMap允许null值(key和value都可以)。
HashTable使用Enumeration,HashMap使用Iterator。
HashMap把Hashtable的contains方法去掉了,改成containsvalue和containsKey。
Hashtable是基于陈旧的Dictionary类,完成了Map接口;HashMap是Java 1.2引进的Map接口的一个实现(HashMap继承于AbstractMap,AbstractMap完成了Map接口)。
HashTable中hash数组默认大小是11,增加的方式是 old*2+1。HashMap中hash数组的默认大小是16,而且一定是2的指数。
哈希值的使用不同,HashTable直接使用对象的hashCode。
2.什么是java的序列化?如何实现java的序列化:

序列化就是一种用来处理对象流的机制,所谓对象流也就是将对象的内容进行流化。可以对流化后的对象进行读写操作,也可将流化后的对象传输于网络之间。序列化是为了解决在对对象流进行读写操作时所引发的问题。

序列化的实现:将需要被序列化的类实现Serializable接口,然后使用一个输出流(如:FileOutputStream)来构造一个ObjectOutputStream(对象流)对象,接着,使用ObjectOutputStream对象的writeObject(Object obj)方法就可以将参数为obj的对象写出(即保存其状态),要恢复的话则用输入流。

3.什么是java的单例模式?写一个单例模式;
单例模式:确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。这个类称为单例类。

  代码清单1:饿汉式单例类

public class EagerSingleton 

    private static final EagerSingleton m_instance = new EagerSingleton(); 

   /** 
   * 私有的默认构造方法 
   */
 
   private EagerSingleton() { } 

   /** 
   * 静态方法获得单例 
   */ 
   public static EagerSingleton getInstance() 
   {
      return m_instance; 
   }
}

代码清单2:懒汉式单例类

package com.javapatterns.singleton.demos;
public class LazySingleton
{
    private static LazySingleton m_instance = null;


    /**
    * 私有的默认构造方法,保证外界无法直接实例化
    */
    private LazySingleton() { }


    /**
    * 静态方法,返还此类的惟一实例
    */
    public synchronized static LazySingleton getInstance()
    {
        if (m_instance == null)
        {
            m_instance = new LazySingleton();
        }
        return m_instance;
    }
}

4.静态块与构造器在继承中的执行顺序:

public class TestExeuteOrder {

public static void main(String[] args) {
Parent p = new ChildTest();
p = new ChildTest();

}

}
class ChildTest extends Parent{
static{
System.out.println("in child static");
}
public ChildTest(){
System.out.println("in child construtor");
}
}

class Parent{
static{
System.out.println("in parent static");
}
public Parent(){
System.out.println("in parent construtor");
}
}
运行结果:
in parent static
in child static
in parent construtor
in child construtor
in parent construtor
in child construtor
5.成员内部类:
public class TestExeuteOrder{
class Inner{
void test(){
if(TestExeuteOrder.this.flag){
System.out.println("what a funny");
}
}
}
private boolean flag = true;
public TestExeuteOrder(){
new Inner().test();
}
public static void main(String[] args){
new TestExeuteOrder();
}
}
运行结果:
what a funny
6.参数传递:
public class TestExeuteOrder{

public static void main(String[] args){
String a = "ello";
TestExeuteOrder t = new TestExeuteOrder();
t.change(a);
System.out.println(a);
}
public void change(String str){
str += "H";
}
}
结果:
ello
7.参数传递2:
public class TestExeuteOrder{

public static void main(String[] args){
StringBuffer x = new StringBuffer("A");
StringBuffer y = new StringBuffer("B");
change(x,y);
System.out.println(x+" "+y);
}
public static void change(StringBuffer a,StringBuffer b){
a.append(b);
b = a;
}
}
结果为:
AB B
8.

public class TestExeuteOrder{
public static void main(String[] args){
String a = "good";
char[] b = new char[]{'a','b','c'};
method(a,b);
System.out.println("a="+a+"------>b="+new String(b));
}
public static void method(String a,char[] b){
a = "Test ok";
b[0] = 'g';
}
}
结果:
a=good------>b=gbc
三、SQL:

 

1.存储过程与函数的区别:
1)前者,程序头部声明用的是procedure;后者,程序头部声明用的是function;
2)前者,不需要描述返回类型,后者需要;
3)前者可以作为一个独立的pl/sql语句来执行;后者不能独立运行,必须作为表达式的一部分条用;
4)sql语句中不可调用procedure,但可以调用function;
2.查询student表中name重复的记录:

select * from student where name in(select name from student group by sname having count(*) >1);

3.table表中有两列A,B,如果A>B选择A,如果A<B,选择B:

select( case when s1.A>s1.B then s1.A  when s1.A<s1.B then s1.B end) re from student s1;

 

posted @ 2012-03-30 16:00 GavinMiao 阅读(717) | 评论 (0)编辑 收藏

异常积累:NoClassDefFoundError: org/hibernate/ConnectionReleaseMode Error creating bean with name 'sessionFactory'

jar包不全,更新lib目录后,不再报错。

posted @ 2012-03-28 16:06 GavinMiao 阅读(381) | 评论 (0)编辑 收藏

公司口碑及待遇评价的网站

1.公司速查手册 :http://www.b1.tooyard.com/
2.分智网:http://www.fenzhi.com/  
3.我评it:http://wopingit.com/   
4.企业点评网:http://www.71dp.com/   
5.中国企业评价网: http://www.ceea.net.cn/  
6.公司点评网:http://www.gsdpw.com/  
7.企业付费邀请面试:http://www.tradecv.com/

posted @ 2012-03-27 23:13 GavinMiao 阅读(1008) | 评论 (1)编辑 收藏

ftp-java实现

一、利用框架:
1.jre下的rt.jar中sun.net.ftpClient
2.common net 中的ftp包
二、ftp协议认识:
参考规范:RFC 959
1.文件传输协议:file transfer protocol (ftp)
2.名词解释:
DTP:
数据传输过程
EOR:记录尾
PI:协议解释器
NTV:
网络虚拟终端
NVFS:
网络虚拟文件系统
3.
控制连接是建立在USER-PIT和SERVER-PI之间用于交换命令与应答的通信链路。
4.
数据连接是传输数据的全双工连接。传输数据可以发生在服务器DTP和用户DTP之间也可以发生在两个服务器DTP之间。
5.
数据连接只传输数据,控制连接传送命令和响应。
6.
FTP使用Telnet协议进行控制连接
7.




参考文章:http://blog.csdn.net/williamzhou/article/details/215293 

posted @ 2012-03-26 18:03 GavinMiao 阅读(368) | 评论 (0)编辑 收藏

ssh集成中session的管理(转载)

     摘要: 文章来源:http://www.iteye.com/topic/7339711.通过getSession()方法获得session进行操作 Java代码  public class Test  extends HibernateDaoSupport{      ...  阅读全文

posted @ 2012-03-23 15:33 GavinMiao 阅读(4701) | 评论 (0)编辑 收藏

spring2.0学习笔记

一、setter DI:
<bean>
    <property name="">
        <ref bean="bean的name或id"/>
    </property>
    <property name="">
        <!--内部bean-->
        <bean></bean>
    </property>
    <property name="">
        <ref local="只能是同一文件的bean的id"/>
    </property>
    <!--idref元素用来引用其它bean的id,spring会验证id是否存在-->
    <property name="">
        <idref bean=""/>
    </property>
    <!--idref元素的local属性用来引用其它bean的id,spring会验证id是否存在,并且验证与引用的bean是否在同一文件-->
    <property name="">
        <idref local=""/>
    </property>
    <property name="">
        <value></value>
    </property>
    <property name="" ref=""/>
    <property name="" value=""/>
    <property name="">
        <null/>
    </property>
    <property name="">
            <props>
                <prop key=""></prop>
                 <prop key=""></prop>
            </props>
    </property>

    <property name="">
        <list>
            <value></value>
            <ref bean=""/>    
        </list>
    </property>

    <property name="">
        <set>
            <value></value>
            <ref bean=""/>    
        </set>
    </property>

    <property name="">
        <map>
            <entry>
                <key>
                    <value></value>
                </key>
                <value></value>
            </entry>
            <entry key="" value=""/><!--推荐-->
            <entry key="">
                <value>
                </value>
            </entry>
            <entry key-ref="" value-ref=""/>
            <entry>
                <key>
                    <value></value>
                </key>
                <ref bean=""/>
            </entry>
        </map>
    </property>
</bean>
二、contructor DI:
<bean>
    <constructor-arg>
        <ref bean=""/>
    </constructor-arg>
    <constructor-arg ref="bean的name或id"/>
    <constructor-arg value=""/>
    <constructor-arg type="" value=""/>
    <constructor-arg index="" value=""/><!--首选-->
</bean>

posted @ 2012-03-22 17:52 GavinMiao 阅读(280) | 评论 (0)编辑 收藏

spring1.1学习笔记

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-03-21 17:34 GavinMiao 阅读(58) | 评论 (0)编辑 收藏

spring2.5新特性

1.spring2.5完全支持java1.6
2.完全支持Java EE 5
3.spring2.5提供了完整的annotation集合:@Autowired,以及对JSR-250注解@Resource,@PostConstruct,@PreDestroy
4.在classpath中自动搜索带有annotation的组件。
5.spring2.5加入了对bean(...)pointcut元素的支持,在spring定义的bean命名中对指定的命名进行匹配
6.在spring应用中使用AspectJ加载时织入context:load-time-weaver
7.增加,通过context:load-time-weaver和tx:annotation-driven mode="aspectj"联合使用的注解驱动的事务管理
8.对JPA,升级到支持Open JPA1.0
9.2.5显著的扩充了SimpleJdbcTemplate的功能,引入了SimpleJdbcCall和SimpleJdbcInsert操作对象
10,web层,增加了基于注解的Controller
11.spring2.5引入了基于annotation的MVC编程模型,使用@RequestMapping、@RequestParam、@ModelAttribute等等
12.增加对tiles2的支持
13.引入了sping TestContext Framework,它提供了注解驱动的单元和集成测试支持

posted @ 2012-03-20 17:57 GavinMiao 阅读(488) | 评论 (0)编辑 收藏

spring2.0新特性

1.
引入request scope、session scope和可自定义的scope(hooks)
2.
引入了XML 
Schema的namespace,
简化了配置,包括了对bean属性的各种简化,AOP配置的简化,事务配置的简化,JNDI配置的简化等方面
3.spring2.0集成了AspectJ切入点(pointcut)语言和@AspectJ切面(aspect)声明类型
4.支持@AspectJ注解定义切面
5.提供了JPA的抽象层
6.对于JMS,spring2.0提供异步接受消息
7.对于jdbc,增加了NamedParameterJdbcTemplate、SimpleJdbcTemplate
8.对java1.5的支持,结合AspectJ使用@Transactional、使用AspectJ来为domain object进行依赖注入、@AspectJ、@Required、SimpleJdbcTemplate

posted @ 2012-03-20 17:37 GavinMiao 阅读(279) | 评论 (0)编辑 收藏

window下dos窗口中文乱码解决办法


进入注册表:
HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe
新建DWORD值,然后重命名为:CodePage,修改其值为十进制的936

posted @ 2012-03-20 11:16 GavinMiao 阅读(519) | 评论 (0)编辑 收藏

java中的位运算应用

1, a & 0xff 可得到a对应而二进制的最后8位;
2,左移n位--》表示乘以2的N次方
3,  右移n位-->表示除以2的N次方

posted @ 2012-03-19 16:36 GavinMiao 阅读(354) | 评论 (0)编辑 收藏

spring整合struts2

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-03-16 14:55 GavinMiao 阅读(21) | 评论 (0)编辑 收藏

spring2.0整合struts1(转载)

     摘要: 文章来源:http://hi.baidu.com/liuzhe041/blog/item/e12251dcf2ffe053ccbf1ad2.htmlspring 和struts整合 有3种方式,推荐用第三种。下面一一介绍,不管使用哪种方式,都需要在web.xml 中配置 spring的 监听器Java代码 <context-param>   &n...  阅读全文

posted @ 2012-03-16 10:14 GavinMiao 阅读(267) | 评论 (0)编辑 收藏

spring整合hibernate(annotation方式)

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-03-15 11:08 GavinMiao 阅读(70) | 评论 (0)编辑 收藏

spring整合hibernate

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-03-14 17:42 GavinMiao 阅读(65) | 评论 (0)编辑 收藏

java播放wav的基础代码(转载)

 文章来源:http://hi.baidu.com/breezedancer/blog/item/7eebb499680d8f086e068cb9.html 

import javax.sound.sampled.*;
import java.io.*;
public class TestMusic{
 
 private AudioFormat format;
    private byte[] samples;
 
 public static void main(String args[])throws Exception{
  TestMusic sound =new TestMusic("1.wav");
  InputStream stream =new ByteArrayInputStream(sound.getSamples());
        // play the sound
        sound.play(stream);
        // exit
        System.exit(0);
 }
 
    public TestMusic(String filename) {
        try {
            // open the audio input stream
            AudioInputStream stream =AudioSystem.getAudioInputStream(new File(filename));
            format = stream.getFormat();
            // get the audio samples
            samples = getSamples(stream);
        }
        catch (UnsupportedAudioFileException ex) {
            ex.printStackTrace();
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
   }
   
   public byte[] getSamples() {
        return samples;
    }
   
     private byte[] getSamples(AudioInputStream audioStream) {
        // get the number of bytes to read
        int length = (int)(audioStream.getFrameLength() * format.getFrameSize());

        // read the entire stream
        byte[] samples = new byte[length];
        DataInputStream is = new DataInputStream(audioStream);
        try {
            is.readFully(samples);
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }

        // return the samples
        return samples;
    }
 
 public void play(InputStream source) {

        // use a short, 100ms (1/10th sec) buffer for real-time
        // change to the sound stream
        int bufferSize = format.getFrameSize() *
            Math.round(format.getSampleRate() / 10);
        byte[] buffer = new byte[bufferSize];

        // create a line to play to
        SourceDataLine line;
        try {
            DataLine.Info info =
                new DataLine.Info(SourceDataLine.class, format);
            line = (SourceDataLine)AudioSystem.getLine(info);
            line.open(format, bufferSize);
        }
        catch (LineUnavailableException ex) {
            ex.printStackTrace();
            return;
        }

        // start the line
        line.start();

        // copy data to the line
        try {
            int numBytesRead = 0;
            while (numBytesRead != -1) {
                numBytesRead =
                    source.read(buffer, 0, buffer.length);
                if (numBytesRead != -1) {
                   line.write(buffer, 0, numBytesRead);
                }
            }
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }

        // wait until all data is played, then close the line
        line.drain();
        line.close();

    }


}

posted @ 2012-03-14 14:30 GavinMiao 阅读(1449) | 评论 (0)编辑 收藏

informix小知识

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-03-13 17:05 GavinMiao 阅读(61) | 评论 (0)编辑 收藏

延迟加载

也叫延迟检索或懒加载
一.实现方式:
1.*hbm.xml中的class元素的lazy属性设置为true;
2.*hbm.xml中的set元素的lazy属性设置为true;
3.
@[One|Many]ToOne](fetch=FetchType.LAZY) @LazyToOne(PROXY) @Fetch(SELECT)
@[One|Many]ToOne](fetch=FetchType.EAGER) @LazyToOne(FALSE) @Fetch(JOIN)
@ManyTo[One|Many](fetch=FetchType.LAZY) @LazyCollection(TRUE)@Fetch(SELECT)
@ManyTo[One|Many](fetch=FetchType.EAGER) @LazyCollection(FALSE) @Fetch(JOIN)

参考文章:

posted @ 2012-03-13 10:46 GavinMiao 阅读(331) | 评论 (0)编辑 收藏

hibernate注意点

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-03-13 09:53 GavinMiao 阅读(57) | 评论 (0)编辑 收藏

commit()与flush()的区别

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-03-13 09:23 GavinMiao 阅读(68) | 评论 (0)编辑 收藏

load与get的区别

1.如果数据库没有匹配的记录,load()方法可能会抛出无法恢复的异常(unrecoverable exception);get()方法会返回null;
2.load可以使用延迟加载;get不可以;


load与get的工作原理:
get方法首先查询session缓存,没有的话查询二级缓存,最后查询数据库;
若设置了lazy=true,load方法创建时首先查询session缓存,没有就创建代理,实际使用数据时才查询二级缓存和数据库;
未设置lazy=true时,与get方法相同;
注意:
到底使用谁:如果不确定是否有匹配的行存在,应该使用get方法。

posted @ 2012-03-13 09:02 GavinMiao 阅读(251) | 评论 (0)编辑 收藏

Linux系统参数查询命令

查看操作系统版本:
head -n 1 /etc/issue
Red Hat Enterprise Linux Server release 6.0 (Santiago)
查看cpu信息:
cat /proc/cpuinfo
model name      : Intel(R) Xeon(R) CPU           E5450  @ 3.00GHz
查看内存使用情况:
free -m
查看各分区使用情况:
df -h 
查看指定目录的大小
du -sh <目录名>
查看内存总量:
grep MemTotal /proc/meminfo
查看空闲内存量:
grep MemFree /proc/meminfo
查看实时的内存情况:
top

posted @ 2012-03-12 15:06 GavinMiao 阅读(588) | 评论 (0)编辑 收藏

呼叫中心企业

参考:http://www.ctiforum.com/expo/2012/ccec2012spring/010.htm 

华为技术有限公司
阿尔卡特朗讯
Genesys,阿尔卡特朗讯旗下公司
Dialogic公司
中国联通
中国电信集团号百信息服务有限公司
北京英立讯科技有限公司
杭州远传通信技术有限公司
奥迪坚通讯系统(上海)有限公司
缤特力贸易(苏州)有限公司
新太科技股份有限公司
深圳市东进通讯技术股份有限公司
Teleopti
广州市毅航通信技术有限公司
潮流网络技术有限公司
杭州三汇信息工程有限公司
亿迅(中国)软件有限公司
大唐高鸿数据网络技术股份有限公司
深圳市友邻通讯设备有限公司
北京易才博普奥管理顾问有限公司
北京天润融通科技有限公司
广州市杰音通讯科技有限公司
北京直真信通科技有限公司
广州市北恩电声技术有限公司
北京七星蓝图科技有限公司
北京科特尔泰讯科技有限公司
北京云端时代科技有限公司
北京宏盛高新技术有限公司
北京纽曼腾飞科技有限公司

posted @ 2012-03-09 15:26 GavinMiao 阅读(263) | 评论 (0)编辑 收藏

javascript面向对象

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2012-03-09 11:14 GavinMiao 阅读(79) | 评论 (0)编辑 收藏

不同厂商JDK下载网址



各厂商JDK官网下载地址: 
1、Oracle JDK,介质分32位和64位,分Linux、Solaris、Windows平台 
http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html 
2、HP JDK,介质不分32位和64位,分PA和IA平台 
https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPUXJDKJRE60 
3、IBM JDK,介质分32位和64位 
https://www.ibm.com/developerworks/java/jdk/aix/service.html#i1 


参考文章:
http://shuwen.iteye.com/blog/1149992

posted @ 2012-03-08 15:30 GavinMiao 阅读(849) | 评论 (0)编辑 收藏

转载:Response.ContentType 详细列表

文章来源:http://www.cnblogs.com/chenghm2003/archive/2008/10/19/1314703.html

不同的ContentType 会影响客户端所看到的效果.默认的ContentType为 text/html 也就是网页格式.
代码如:
<% response.ContentType ="text/html" %> 
<!--#i nclude virtual="/ContentType.html" -->

显示的为网页,而
<% response.ContentType ="text/plain" %> 
<!--#i nclude virtual="/sscript/ContentType.html" -->

则会显示html原代码.

以下为一些常用的 ContentType
GIF images 
<% response.ContentType ="image/gif" %> 
<!--#i nclude virtual="/myimage.gif" -->

JPEG images 
<% response.ContentType ="image/jpeg" %> 
<!--#i nclude virtual="/myimage.jpeg" -->

TIFF images 
<% response.ContentType ="image/tiff" %> 
<!--#i nclude virtual="/myimage.tiff" -->

MICROSOFT WORD document 
<% response.ContentType ="application/msword" %> 
<!--#i nclude virtual="/myfile.doc" -->

RTF document 
<% response.ContentType ="application/rtf" %> 
<!--#i nclude virtual="/myfile.rtf" -->

MICROSOFT EXCEL document 
<% response.ContentType ="application/x-excel" %> 
<!--#i nclude virtual="/myfile.xls" -->

MICROSOFT POWERPOINT document 
<% response.ContentType ="application/ms-powerpoint" %> 
<!--#i nclude virtual="/myfile.pff" -->

PDF document 
<% response.ContentType ="application/pdf" %> 
<!--#i nclude virtual="/myfile.pdf" -->

ZIP document 
<% response.ContentType ="application/zip" %> 
<!--#i nclude virtual="/myfile.zip" -->



下面是更详细的ContentType
'ez' => 'application/andrew-inset', 
'hqx' => 'application/mac-binhex40', 
'cpt' => 'application/mac-compactpro', 
'doc' => 'application/msword', 
'bin' => 'application/octet-stream', 
'dms' => 'application/octet-stream', 
'lha' => 'application/octet-stream', 
'lzh' => 'application/octet-stream', 
'exe' => 'application/octet-stream', 
'class' => 'application/octet-stream', 
'so' => 'application/octet-stream', 
'dll' => 'application/octet-stream', 
'oda' => 'application/oda', 
'pdf' => 'application/pdf', 
'ai' => 'application/postscript', 
'eps' => 'application/postscript', 
'ps' => 'application/postscript', 
'smi' => 'application/smil', 
'smil' => 'application/smil', 
'mif' => 'application/vnd.mif', 
'xls' => 'application/vnd.ms-excel', 
'ppt' => 'application/vnd.ms-powerpoint', 
'wbxml' => 'application/vnd.wap.wbxml', 
'wmlc' => 'application/vnd.wap.wmlc', 
'wmlsc' => 'application/vnd.wap.wmlscriptc', 
'bcpio' => 'application/x-bcpio', 
'vcd' => 'application/x-cdlink', 
'pgn' => 'application/x-chess-pgn', 
'cpio' => 'application/x-cpio', 
'csh' => 'application/x-csh', 
'dcr' => 'application/x-director', 
'dir' => 'application/x-director', 
'dxr' => 'application/x-director', 
'dvi' => 'application/x-dvi', 
'spl' => 'application/x-futuresplash', 
'gtar' => 'application/x-gtar', 
'hdf' => 'application/x-hdf', 
'js' => 'application/x-javascript', 
'skp' => 'application/x-koan', 
'skd' => 'application/x-koan', 
'skt' => 'application/x-koan', 
'skm' => 'application/x-koan', 
'latex' => 'application/x-latex', 
'nc' => 'application/x-netcdf', 
'cdf' => 'application/x-netcdf', 
'sh' => 'application/x-sh', 
'shar' => 'application/x-shar', 
'swf' => 'application/x-shockwave-flash', 
'sit' => 'application/x-stuffit', 
'sv4cpio' => 'application/x-sv4cpio', 
'sv4crc' => 'application/x-sv4crc', 
'tar' => 'application/x-tar', 
'tcl' => 'application/x-tcl', 
'tex' => 'application/x-tex', 
'texinfo' => 'application/x-texinfo', 
'texi' => 'application/x-texinfo', 
't' => 'application/x-troff', 
'tr' => 'application/x-troff', 
'roff' => 'application/x-troff', 
'man' => 'application/x-troff-man', 
'me' => 'application/x-troff-me', 
'ms' => 'application/x-troff-ms', 
'ustar' => 'application/x-ustar', 
'src' => 'application/x-wais-source', 
'xhtml' => 'application/xhtml+xml', 
'xht' => 'application/xhtml+xml', 
'zip' => 'application/zip', 
'au' => 'audio/basic', 
'snd' => 'audio/basic', 
'mid' => 'audio/midi', 
'midi' => 'audio/midi', 
'kar' => 'audio/midi', 
'mpga' => 'audio/mpeg', 
'mp2' => 'audio/mpeg', 
'mp3' => 'audio/mpeg', 
'aif' => 'audio/x-aiff', 
'aiff' => 'audio/x-aiff', 
'aifc' => 'audio/x-aiff', 
'm3u' => 'audio/x-mpegurl', 
'ram' => 'audio/x-pn-realaudio', 
'rm' => 'audio/x-pn-realaudio', 
'rpm' => 'audio/x-pn-realaudio-plugin', 
'ra' => 'audio/x-realaudio', 
'wav' => 'audio/x-wav', 
'pdb' => 'chemical/x-pdb', 
'xyz' => 'chemical/x-xyz', 
'bmp' => 'image/bmp', 
'gif' => 'image/gif', 
'ief' => 'image/ief', 
'jpeg' => 'image/jpeg', 
'jpg' => 'image/jpeg', 
'jpe' => 'image/jpeg', 
'png' => 'image/png', 
'tiff' => 'image/tiff', 
'tif' => 'image/tiff', 
'djvu' => 'image/vnd.djvu', 
'djv' => 'image/vnd.djvu', 
'wbmp' => 'image/vnd.wap.wbmp', 
'ras' => 'image/x-cmu-raster', 
'pnm' => 'image/x-portable-anymap', 
'pbm' => 'image/x-portable-bitmap', 
'pgm' => 'image/x-portable-graymap', 
'ppm' => 'image/x-portable-pixmap', 
'rgb' => 'image/x-rgb', 
'xbm' => 'image/x-xbitmap', 
'xpm' => 'image/x-xpixmap', 
'xwd' => 'image/x-xwindowdump', 
'igs' => 'model/iges', 
'iges' => 'model/iges', 
'msh' => 'model/mesh', 
'mesh' => 'model/mesh', 
'silo' => 'model/mesh', 
'wrl' => 'model/vrml', 
'vrml' => 'model/vrml', 
'css' => 'text/css', 
'html' => 'text/html', 
'htm' => 'text/html', 
'asc' => 'text/plain', 
'txt' => 'text/plain', 
'rtx' => 'text/richtext', 
'rtf' => 'text/rtf', 
'sgml' => 'text/sgml', 
'sgm' => 'text/sgml', 
'tsv' => 'text/tab-separated-values', 
'wml' => 'text/vnd.wap.wml', 
'wmls' => 'text/vnd.wap.wmlscript', 
'etx' => 'text/x-setext', 
'xsl' => 'text/xml', 
'xml' => 'text/xml', 
'mpeg' => 'video/mpeg', 
'mpg' => 'video/mpeg', 
'mpe' => 'video/mpeg', 
'qt' => 'video/quicktime', 
'mov' => 'video/quicktime', 
'mxu' => 'video/vnd.mpegurl', 
'avi' => 'video/x-msvideo', 
'movie' => 'video/x-sgi-movie', 
'ice' => 'x-conference/x-cooltalk' 


posted @ 2012-03-07 13:13 GavinMiao 阅读(230) | 评论 (0)编辑 收藏

throws与throw的区别

1.throw是语句抛出一个异常,throws是方法抛出异常;
2.throws可声明多个异常,用逗号分割;
3.throws可单独使用,throw必须与try-catch-finally或throws搭配使用;
4.throws表示可能抛出哪些异常,throw是必定抛出这个异常;

posted @ 2012-03-06 09:48 GavinMiao 阅读(327) | 评论 (0)编辑 收藏