参考这个
http://www.cnblogs.com/wangshenhe/archive/2012/05/09/2490438.html
http://www.cnblogs.com/zcttxs/archive/2012/06/12/2546293.html
http://www.cnblogs.com/hlxs/archive/2011/05/18/2087974.html