锘??xml version="1.0" encoding="utf-8" standalone="yes"?>BlogJava-JAVA瀛範绗旇http://www.67529968.com/lingy/zh-cnMon, 25 Feb 2019 15:20:07 GMTMon, 25 Feb 2019 15:20:07 GMT60vim 鏇挎崲http://www.67529968.com/lingy/archive/2012/05/09/377726.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Wed, 09 May 2012 09:28:00 GMThttp://www.67529968.com/lingy/archive/2012/05/09/377726.html:%s/143250/143120/g



]]>
[绔?#37721;?#29722;崰鐢?鐜?#28583;?#29863;蜂笉鏉]甯歌娴?#29831;?#37916;?#28583;?#38338;?#26864;?#29785;喅http://www.67529968.com/lingy/archive/2012/01/31/369065.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Tue, 31 Jan 2012 03:29:00 GMThttp://www.67529968.com/lingy/archive/2012/01/31/369065.html澶?#28729;?#37828;惁閬囧埌閮讲鐜?#28583;?#37928;勬椂鍊?绔?#37721;?#29722;崰鐢?鐜?#28583;?#29863;蜂笉鏉?#37928;?#38338;?#26864;?#37723;紵閬囧埌杩欎釜鎯呭喌,鎴戜滑璇?#28641;?#28003;?#29785;喅鍛紵

涓嬮潰鎴戞妸鎴?#38316;囧埌杩欎釜闂?#26864;?#29785;喅鐨勬?#35268;硶鎬荤粨涓?#38171;?/span>

鐜拌薄鏄?#26473;?#37837;?#37928;?

1. 椤甸潰璁?#38338;?#37713;?#37916;? Http 500

2. 鍚?#37721;?#37722;姩鏃織鎻愮: 

vodka init successfully!!! ...

start apache ......

(98)Address already in use: make_sock: could not bind to address [::]:5071

no listening sockets available, shutting down

Unable to open logs

瑙喅鏂规硶: 鏉鎺夊崰鐢?#37928;勮?#28058;

棣栧厛,闇瑕?#37922;root璐?#37721;风?#23130;檰,鐧婚檰鍚?杈撳叆: netstat -plan |grep 5070

鍑?#37916;?#28641;?#28051;?


[Intranet root@qa-kernal-143-41 /root]

#netstat -plan |grep 5070

tcp 0 0 :::5070 :::* LISTEN 28002/httpd 

tcp 1 0 ::ffff:10.20.143.41:5070 ::ffff:10.16.46.75:4654 CLOSE_WAIT 28406/httpd 

鏈鍚?#37833;鎺夊崰鐢?#37928;勮?#28058;,杈撳叆:   lsof -i:5070 鍗?#37721;?(娉?070鏄?#32468;?#37721;?#37721;?

[Intranet root@qa-kernal-143-41 /root]

#lsof -i:5070

]]>
linux鐢?#37812;风?#21229;浉鍏崇煡璇?/title><link>http://www.67529968.com/lingy/archive/2012/01/31/369064.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Tue, 31 Jan 2012 03:28:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2012/01/31/369064.html</guid><description><![CDATA[<span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">鐢root鐢?#37812;风?#23130;檰杈撳叆鍛戒护cd /home锛?#37712;?#37922;ll?#29025;?#28229;鍙?#37916;癲rwxr-xr-x 12 622   622    4096 Apr 18 19:21 aurora  aurora鐢?#37812;?#28766;?#28051;讳笉姝?#32429;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">鐢?#37723;戒护chown aurora.aurora aurora淇敼鐢?#37812;?#28766;?#28051;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">?#29025;璇?#37904;?#38171;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">1.?#29025;?#28229;鐢?#37812;风粍淇?#37805;?cat /etc/passwd</span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">/etc/passwd涓?#28051;琛?#29825;?#35120;曞搴旂潃涓?#37340;鐢?#37812;?#38171;?#23011;?#29723;?#37922;?#37712;?#37721;烽殧寮鍒?#28051;??#37340;瀛?#23048;?#38171;?#37711;蜂綋瀛?#23048;?#29831;?#37828;庡涓?#38171;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(255,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">name:password:uid:gid:comment:home:shell<br style="outline-style: none" />鐢?#37812;?#37722;?鍙护:鐢?#37812;?#37837;?#29831;?#37721;?缁勬爣璇?#37721;?娉噴鎬?#37819;?#26473;?涓荤洰褰?鐧?#35120;Shell</span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">home: 鎸囧畾鐢?#37812;?#37928;?#28051;荤洰褰?#37928;?#32513;?#28725;硅矾寰?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">shell: 鐢?#37812;风?#23130;檰鍚?#37722;姩鐨?#28051;?#37340;杩涚锛?#26473;欎釜杩涚鏄?#37922;?#37812;风櫥褰曞埌绯荤粺鍚?#26473;?#29723;?#37928;?#37723;戒护瑙噴鍣?#37812;?#37836;愪釜鐗瑰畾鐨勭搴?#38171;?#37719;砈hell銆?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">渚?#28699;?#38171;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">aurora:x:707:707::/home/aurora:/bin/bash</span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">   绯荤粺棣栧厛?#32048;?#29025;闃?/etc/passwd 鏂?#28000;?#38171;岀湅鏄惁鏈塧urora 杩欎釜璐?#37721;?#38171;岀劧鍚?#32429;畾aurora鐨刄ID锛岄?#26473;UID 鏉?#32429;?#29825;?#37922;?#37812;峰?#23683;韩浠?#38171;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">   濡?#37835;?#28699;樺湪鍒?#29831;?#37721;?etc/shadow 褰?#28699;?#37826;?#28000;?#28051;墍瀵?#25652;?#37928;刟urora鐨勫瘑鐮?#38171;?nbsp; <span class="Apple-converted-space"> </span></span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">   鐢?#37812;?#37722;?#38171;x锛歶id锛歡id锛?#37922;?#37812;?#37722;?#37711;?#32457;?#38171;?#37922;?#37812;?#37928;?#28729;?#38171;?#37922;?#37812;锋墍鐢?#37928;剆hell绫诲瀷</span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">  x鎸囧悜鏄犲皠</span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">uid涓? 鍒欎负root  </span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">2.aurora:$1$nC4FzXJz$OP5LS0Evj4uMsLvMHP1eZ/:15082:0:99999:7:::</span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">etc/shadow鏂?#28000;?#37828;?etc/passwd 鐨?#35120;?#28699;?#37826;?#28000;?#38171;?#26473;欎釜鏂?#28000;?#39582;朵笉鐢?etc/passwd 鑰屼骇鐢?#37928;?#38171;?#26473;欎袱?#37340;鏂?#28000;?#37828;?#25652;旇鏄?#28725;?#25652;?#27996;?#29723;?#37928;?#38171;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">shadow鍐呭?#29808;?#21614;嫭鐢?#37812;?#37721;?#29722;?#37716;犲瘑鐨勫瘑鐮?#37721;?#37711;?#28000;?etc/passwd ?#31497;?#20824;鍖呮嫭鐨?#28103;?#37805;?#37510;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">鐢?#37812;?#38171;氬瘑鐮?#38171;?#28051;婃淇敼?#30225;鐮?#37928;勬椂闂?锛?#28051;?#23046;?#28103;敼鍙护闂撮殧鏈灏?#37928;?#28598;暟锛?#28051;?#23046;?#28103;敼鍙护闂撮殧鏈澶?#37928;?#28598;暟</span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">3.aurora:x:707:</span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">鐢?#37812;?#37722;?#38171;?#37922;?#37812;风?#21227;瘑鐮?#38171;GID :鐢?#37812;?#37714;?#29723;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">绗洓瀛?#23048;?#38171;?#37922;?#37812;?#37714;?#29723;?#38171;?#23011;忎釜鐢?#37812;蜂箣闂?#37922;?鍙?#37714;嗗壊锛?#37832;?#28699;?#23048;佃兘涓虹锛?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">濡?#37835;?#28699;?#23048;?#28051;虹琛?#32448;?#37922;?#37812;风粍涓GID鐨?#37922;?#37812;?#37722;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">4.chown 淇敼鏂?#28000;跺拰鏂?#28000;?#28598;?#37928;?#37922;?#37812;峰拰鐢?#37812;风粍灞?#37804;?/span><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; outline-style: none; font: 14px/24px Arial; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="widows: 2; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/24px Arial; white-space: normal; orphans: 2; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">5.passwd aurora 淇敼?#30225;鐮?/span><img src ="http://www.67529968.com/lingy/aggbug/369064.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2012-01-31 11:28 <a href="http://www.67529968.com/lingy/archive/2012/01/31/369064.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>linux涔?#37922;?#37812;风櫥褰?#37916;?#28583;?#37721;?#38322;?#37714;?#37835;?/title><link>http://www.67529968.com/lingy/archive/2012/01/31/369057.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Tue, 31 Jan 2012 02:53:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2012/01/31/369057.html</guid><description><![CDATA[<strong>鏄?#28598;?#38316;?#29785;?#28051;?#37340;闂?#26864;?#38171;?#28051;?#28598;?#28729;?#37714;嗕韩涓涓?#37510;?#37916;拌薄濡?#28051;?#38171;屽綋浠?#28051;?#37340;鐢?#37812;?#37714;囨崲?#22476;鍙?#28598;?#28051;?#37340;鐢?#37812;?#37510;?#37812;?#38000;?#37929;?#37818;?#37927;?#35120;?#37928;勬椂鍊欎細鍑?#37916;?#28641;傞敊璇?#38171;歜ash-3.2</strong>  <p><strong>鍒?#37835;?#38171;?/strong></p> <p><strong>鑰?#28051;攂pm杩欎釜鐢?#37812;蜂互鍓?#38318;?#37828;?#28610;?#37928;?#38171;?#28051;?#28000;涔?#37723;紵鎴戜滑鏉?#37714;?#37835;?#28051;涓?#37922;?#37812;?#37928;?#37927;?#35120;?#37928;?#28051;浜涘?#29114;?#21975;氨鏄?#37927;戒簡锛?/strong></p> <p><strong>鐢?#37812;峰湪鍒?#37927;?#35120;Linux?#26882;锛屾楠?#28641;?#28051;?#38171;?/strong></p> <p><strong>1</strong><strong>銆?#26851;栧厛鍚姩 /etc/profile 鏂?#28000;?#38171;?/strong></p> <p><strong>2</strong><strong>銆佺劧鍚?#37712;?#37722;姩鐢?#37812;风洰褰?#28051;?#37928;?~/.bash_profile銆?~/.bash_login鎴?~/.profile鏂?#28000;?#28051;?#37928;?#37711;?#28051;?#28051;?#37340;锛?/strong></p> <p><strong>鎵?#29723;?#37928;?#26916;?#25652;?#28051;?#38171;殈/.bash_profile銆?~/.bash_login銆?~/.profile銆?濡?#37835;?~/.bash_profile鏂?#28000;?#28699;樺湪鐨?#29831;?#38171;?#28051;鑸?#26473;樹細鎵?#29723;?~/.bashrc鏂?#28000;?#37510;?/strong></p> <p><strong>鍥?#28051;哄湪 ~/.bash_profile鏂?#28000;?#28051;?#28051;鑸細鏈?#28051;嬮潰鐨?#28000;?#37934;?</strong></p> <p>if [ -f ~/.bashrc ] ; then</p> <p>銆. ./bashrc</p> <p>fi</p> <p> 鍥?#28051;哄湪 ~/.bash_profile鏂?#28000;?#28051;?#28051;鑸細鏈?#28051;嬮潰鐨?#28000;?#37934;?#38171;?br />if [ -f ~/.bashrc ] ; then<br />. ./bashrc<br />fi<br />?#22669;浠?#38171;~/.bashrc?#32048;?#30367;鐢?/etc/bashrc鏂?#28000;?#37510;?/p> <p><strong>3</strong><strong>銆?#37832;鍚?#38171;屽湪閫鍑簊hell?#26882;锛?#26473;樹細鎵?#29723;?~/.bash_logout鏂?#28000;?#37510;?/strong></p> <p><strong>?#22669;浠?#28051;?#37340;鐢?#37812;蜂粠鐧?#35120;曞埌鐧?#37713;?#37928;勬墽琛?#26916;?#25652;?#28051;?#38171;?etc/profile -> (~/.bash_profile | ~/.bash_login | ~/.profile) -> ~/.bashrc ->/etc/bashrc -> ~/.bash_logout</strong></p> <p><strong>褰?#37812;戜滑?#29025;?#28229;褰撳墠鐢?#37812;?#37928;?#38341;愯棌鏂?#28000;?#37510;恖s -al銆?#37828;惁鏈?#26473;欎簺鏂?#28000;?#37928;勬椂鍊?#38171;?#26473;欎簺鏂?#28000;?#38318;?#28051;?#28598;?#27996;?#38171;屾墍浠?#28751;变細鍑?#37916;癰ash-3.2鐨勯敊璇?#37510;備篃灏?#37828;?#37721;栦笉?#22476;褰撳墠鐧?#35120;?#37922;?#37812;?#37928;?#37721;?#38322;?#28725;艰嚧銆?/strong></p> <p><strong>澶?#23049;?#38171;?#37711;?#27996;?#37722;勪釜鏂?#28000;?#37928;?#28003;?#37922;?#37737;?#38171;屽湪缃戜笂鎵惧埌浜?#28000;?#28051;?#29831;?#37828;?#38171;?/strong></p> <p><strong>锛?锛?etc/profile锛?姝?#37826;?#28000;?#28051;虹?#33636;粺鐨勬?#24526;釜鐢?#37812;?#29825;?#32515;?#37916;?#28583;?#28103;?#37805;?褰?#37922;?#37812;?#32471;?#28051;娆?#37927;?#35120;曟椂,璇?#37826;?#28000;?#29722;?#37813;?#29723;? 骞?#28000;?etc/profile.d?#27952;褰?#37928;勯?#23943;疆鏂?#28000;?#28051;?#37820;滈泦shell鐨勮缃?#37510;?/strong></p> <p><strong>锛?锛?etc/bashrc: 涓?#23011;?#28051;?#37340;杩?#29723;宐ash shell鐨?#37922;?#37812;?#37813;?#29723;屾鏂?#28000;?褰揵ash shell琚?#37813;撳紑?#26882;,璇?#37826;?#28000;?#29722;?#29831;?#37721;?#37510;?/strong></p> <p><strong>锛?锛墌/.bash_profile: 姣忎釜鐢?#37812;?#38318;?#37721;?#28003;?#37922;?#29831;?#37826;?#28000;?#26440;撳叆涓?#37922;?#27996;庤嚜?#32321;浣?#37922;?#37928;剆hell淇?#37805;?褰?#37922;?#37812;风櫥褰曟椂,璇?#37826;?#28000;?#28000;?#28000;?#37813;?#29723;?#28051;娆?榛樿鎯呭喌涓?浠?#29825;?#32515;?#28051;浜?#37916;?#28583;?#37721;?#38322;?鎵?#29723;?#37922;?#37812;?#37928;?bashrc鏂?#28000;?#37510;?/strong></p> <p><strong>锛?锛墌/.bashrc: 璇?#37826;?#28000;?#37718;呭惈涓?#37922;?#27996;?#28003;?#37928;刡ash shell鐨刡ash淇?#37805;?褰?#37927;?#35120;曟椂浠?#37721;?#23011;?#23046;?#37813;撳紑鏂?#37928;剆hell?#26882;,璇?#29831;?#37826;?#28000;?#29722;?#29831;?#37721;?#37510;?/strong></p> <p><strong>锛?锛?/strong><strong><sub>/.bash_logout:褰?#23011;?#23046;?#38315;鍑虹?#33636;粺(閫鍑篵ash shell)?#26882;,鎵?#29723;?#29831;?#37826;?#28000;? 鍙?#28598;?/etc/profile涓?#29825;惧畾鐨?#37721;?#38322;?鍏?#28766;)鐨?#37721;?#28000;?#28003;?#37922;?#27996;?#28000;?#28003;?#37922;?#37812;?鑰?/sub></strong><strong>/.bashrc绛?#28051;?#29825;惧畾鐨?#37721;?#38322;?灞閮?鍙兘缁?#37813;?etc/profile涓?#37928;?#37721;?#38322;?浠栦滑鏄?鐖?#28699;?鍏崇郴銆?/strong></p> <p><strong>锛?锛?/strong><strong><sub>/.bash_profile 鏄?#27996;?#27996;?#23534;?#37510;乴ogin 鏂?#23534;?#26473;涘叆 bash 杩?#29723;?#37928;?/sub></strong><strong>/.bashrc 鏄?#27996;?#27996;?#23534;?non-login 鏂?#23534;?#26473;涘叆 bash 杩?#29723;?#37928;勯?#29999;?#27996;岃?#29825;?#32515;?#28598;嚧?#27977;鍚?#38171;屾墍浠?#38315;?#29999;?#37715;?#38000;呬細?#30367;鐢?#37722;庤?#37510;?/strong></p> <p><strong> </strong></p> <p><strong>瑙喅鏂规锛?/strong></p> <p><strong> </strong> <strong>浠庢纭?#37928;?#37916;?#28583;copy杩?/strong><strong>.bash_profile</strong><strong>銆?bashrc銆?bash_logout</strong><strong>涓変釜鏂?#28000;?#28051;?#28000;?#28051;涓?#28598;?#37928;勬枃浠跺埌褰撳墠?#27952;褰?#28051;嬮潰銆?#29825;?#37711;?#37922;熸晥鍗?#37721;?#37510;?/strong></p> <p><strong>浣?#28051;?#28000;涔?#26473;欎?#22793;釜鏂?#28000;?#28051;?#28598;?#37812;戞病鏈?#37813;惧埌鍏?#28051;?#28598;?#37928;勫師鍥?#38171;?#37832;鏍规湰鐨勭寽娴嬪氨鏄?#28598;?#28729;朵笉灏忓績鍒犻櫎浜?#37510;?#37721;?#28598;杔inux鐨?#38338;?#26864;?#37812;戜釜浜?#37928;?#32513;?#26976;屽氨鏄?#26916;?#38040;懜鐡?#37510;?#37818;?#37819;?#37720;熺?#21973;箣鍚庡氨寰?#28598;?#29785;喅浜?#38171;?/strong></p><img src ="http://www.67529968.com/lingy/aggbug/369057.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2012-01-31 10:53 <a href="http://www.67529968.com/lingy/archive/2012/01/31/369057.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>Oracle DDL,DML,DCL,TCL 鍩虹姒傚康 http://www.67529968.com/lingy/archive/2010/08/17/329116.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Tue, 17 Aug 2010 08:50:00 GMThttp://www.67529968.com/lingy/archive/2010/08/17/329116.htmlDDL
Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:
  • CREATE - to create objects in the database
  • ALTER - alters the structure of the database
  • DROP - delete objects from the database
  • TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
  • COMMENT - add comments to the data dictionary
  • RENAME - rename an object

DML

Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:
  • SELECT - retrieve data from the a database
  • INSERT - insert data into a table
  • UPDATE - updates existing data within a table
  • DELETE - deletes all records from a table, the space for the records remain
  • MERGE - UPSERT operation (insert or update)
  • CALL - call a PL/SQL or Java subprogram
  • EXPLAIN PLAN - explain access path to data
  • LOCK TABLE - control concurrency

DCL

Data Control Language (DCL) statements. Some examples:
  • GRANT - gives user's access privileges to database
  • REVOKE - withdraw access privileges given with the GRANT command

TCL

Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.
  • COMMIT - save work done
  • SAVEPOINT - identify a point in a transaction to which you can later roll back
  • ROLLBACK - restore database to original since the last COMMIT
  • SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use


浣?#38000;?#38171;?#37833;庢暚?#21159;锛Gnie锛?br /> 鍑?#28598;?#38171;?a href="http://www.cnblogs.com/gnielee/">{GnieTech} 锛坔ttp://www.cnblogs.com/gnielee/锛?br /> 鐗?#37833;冨鏄?#38171;?#37832;?#37826;?#37928;勭増鏉?#35120;?#28003;?#38000;?#28051;庡瀹?#37733;?#37711;?#37832;?#37510;傝浆杞芥椂椤?#23049;?#37828;?#37832;?#37826;?#37928;?#29831;?#32513;?#38334;?#37818;?#38171;屽惁鍒欎綔鑰呭皢淇濈暀杩界鍏舵硶寰嬭矗浠?#37510;?/p>

]]>
linux 鍛戒护http://www.67529968.com/lingy/archive/2010/08/17/329113.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Tue, 17 Aug 2010 08:28:00 GMThttp://www.67529968.com/lingy/archive/2010/08/17/329113.html 

insert into ali_zeus_access_area
select * from ali_zeus_access_area@zeus_dev;

script -q tty.log

sqlplus /nolog
conn rnd/mCQe88il@crmintsb
conn rnd/mCQe88il@crmint


scp tty.log guangyan.lingy@10.20.130.14:/home/guangyan.lingy/tty0601.log

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
sqlplus rnd/mCQe88il@crmg

for remote in \
172.16.131.47 172.16.131.48 172.16.131.49 172.16.131.50 172.16.131.51 172.16.131.52 172.16.131.53 172.16.131.54 172.16.131.55 172.16.131.2 172.16.131.3 172.16.131.4 172.16.131.5 172.16.131.6 172.16.131.7 172.16.131.41 172.16.131.42 172.16.131.56 172.16.131.57 172.16.131.58 \
;do echo $remote; ssh $remote "grep 'sms webService visitor IP is' output/logs/user/martini_sales_tool.log"; done

 

daisy.louy
 louying
 
 
carvin hello123
http://svn.alibaba-inc.com/repos/crm/martini/branches/20091209_dcs_guangyan.lingy_dev

weiming.shi
jinbo.yu
1234567890 alibaba-guest
鎴?#37714;?#37721;?#29831;?#27996;?/p>


涓?#37733;?#37928;?#37719;?#28598;?#28729;?#28766;呭?#24531;煄,涓?#37719;?#37928;勬椂鍊欑湅鐨?br /> http://focus.news.163.com/10/0531/09/680LGN5L00011SM9.html
鏈?#23049;夊窞:)

?#26271;鎹?#22959;瀷璧勬簮鎵?#37712;?/p>

闇瑕?#28003;庣鏃?#37719;?#38339;荤噧鐢?#32514;?#37826;?#37928;?#37922;?#32514;嗕紒涓?/p>

]]>
銆?#29825;?#29825;?#22959;?#23534;?#37510;?#28052;婮ava瑙?#29831;?-妗?#37818;Bridge http://www.67529968.com/lingy/archive/2010/07/29/327422.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Thu, 29 Jul 2010 05:56:00 GMThttp://www.67529968.com/lingy/archive/2010/07/29/327422.html闃?#29831;?#37711;?#37826;?/a>

]]>
鏃犳硶?#30078;浣?#32459;?#25652;?#26440;撳叆鐐筥except_handler4_common浜庡姩鎬侀摼鎺?#25652;msvcrt.dll涓?/title><link>http://www.67529968.com/lingy/archive/2010/07/05/325279.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Mon, 05 Jul 2010 06:12:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2010/07/05/325279.html</guid><description><![CDATA[<p>鏈杩?#38171;?#28598;氱?#23944;蒋浠?#38318;?#37713;?#37916;?#27996;?#28051;?#37340;鍚姩?#26882;鐨勯敊璇?#37819;愮 “鏃犳硶?#30078;浣?#32459;?#25652;?#26440;撳叆鐐筥except_handler4_common浜庡姩鎬侀摼鎺?#25652;msvcrt.dll涓?#8221;銆?/p> <p>鍑?#37916;?#26473;欎釜鎻愮鎯呭喌鏄?#38171;Windows Xp 绯荤粺锛?杞?#28000;?#37718;呮嫭锛歸indow live writer 2009, windows messenger 2009, firefox 3.5 绛?#38344;?#29999;?#37826;?#37928;勭増鏈?#37510;?/p> <p>杩欎釜鎻愮鍑?#37916;?#37722;?#38171;?#37904;?#37713;荤?#30078;锛屽?#26421;笉褰卞搷绋?#25652;?#37928;?#28003;?#37922;?#37510;?#26473;欎釜闂?#26864;?#37713;?#37916;?#37928;勫師鍥?#38171;?#37711;?#28729;?#23536;?#26462;?#38007;繁鐨?#38338;?#26864;?#37510;?#37721;?#29835;?#37828;?#23536;?#26462;?#37928;刅ista 鍚?#38316;?#37925;囧惂銆?/p> <p>?#28266; Vista 绯荤粺閲?#38171;?#37832;変釜鎸洪叿鐨?#37716;熻兘锛屽氨鏄?#8220;绋?#25652;?#32514;暐鍥?#8221;锛?#37832;?#37904;?D鏁?#37835;?#38171;?#26473;欎釜鍔熻兘锛岃皟鐢?#27996;?dwmapi.dll 杩欎釜搴?#38171;岃?dwmapi.dll 鍙?#23534;?#37922;?#27996;?msvcrt.dll 涓?#37928;?_except_handler4_common 鍔熻兘銆?/p> <p>?#21159;鑰?#38171;屽湪XP绯荤粺涓?#38171;?#32495;荤粺鑷?#29999;?#37928;?msvcrt.dll  ?#25328; Vista 涓?#37928;?msvcrt.dll 鐗?#37832;笉鍚?#38171;?骞舵病鏈?#26473;欎釜 _except_handler4_common 锛岀粨鏋?#28751;?#37713;?#37916;?#27996;?#37722;姩绋?#25652;忔椂锛?#38316;囧埌鐨?“鏃犳硶?#30078;浣?#32459;?#25652;?#26440;撳叆鐐筥except_handler4_common浜庡姩鎬侀摼鎺?#25652;msvcrt.dll涓?#8221;鐨勯敊璇?#37819;愮銆?/p> <p><strong>瑙喅鏂规硶</strong>锛?/p> <div class="content-sub-title">      灏?c:\windows\system32 涓?#37928;?dwmapi.dll ?#25980;鍚?#38171;?#28186;?#28641;?#38171;氭敼涓?dwmapi.dll.bak銆?/div> <img src ="http://www.67529968.com/lingy/aggbug/325279.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2010-07-05 14:12 <a href="http://www.67529968.com/lingy/archive/2010/07/05/325279.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>oracle 鍥炴粴 sql鎿?#28003;?/title><link>http://www.67529968.com/lingy/archive/2010/06/02/322585.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Wed, 02 Jun 2010 08:31:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2010/06/02/322585.html</guid><description><![CDATA[select * from ali_zeus_opportunity as of timestamp to_timestamp('2010-6-2 12:00:00','yyyy-mm-dd hh24:mi:ss');<br /> <img src ="http://www.67529968.com/lingy/aggbug/322585.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2010-06-02 16:31 <a href="http://www.67529968.com/lingy/archive/2010/06/02/322585.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>Eclipse 鍚姩杩?#29723;岄?#25652;皟浼?http://www.67529968.com/lingy/archive/2009/10/01/297077.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Thu, 01 Oct 2009 03:24:00 GMThttp://www.67529968.com/lingy/archive/2009/10/01/297077.html

JVM 鎻愪緵浜?#37722;勭鐢?#27996;庤皟鏁?#37712;?#28699;?#37714;嗛厤鍜屽?#20904;溇鍥?#37824;?#29723;?#28051;?#37928;勬?#22247;噯寮鍏冲?#23684;潪鏍囧噯寮鍏?#37510;?#37711;?#28051;?#28051;浜?#29825;?#32515;?#37721;?#28000;?#37819;珮 JAVA IDE 鐨勬兘銆?
娉剰锛?#37922;?#27996;?-X 锛?#28751;?#37711;?#37828;?-XX JVM锛夊紑鍏?#38315;?#29999;?#37828;?JVM 鎴?JVM 渚?#25652;?#37727;?#37911;瑰畾鐨?#38171;?#37832;?#38318;?#37714;?#28000;?#32513;?#37928;?#23534;鍏?#37721;?#37922;?#27996;?Sun Microsystems J2SE 1.4.2銆?/p>

浠?#28051;嬭缃湪澶?#28598;氭暟绯荤粺涓?#28751;嗕骇鐢?#23011;?#23480;?#37720;?#37831;?#28610;?#37928;勮缃?#37804;兘銆?
-vmargs - 琛?#32448;?#28751;?#37722;庨潰鐨勬墍鏈?#37721;傛暟鐩?#37818;?#28028;?#38315;掑埌?#22669;鎸囩鐨?Java VM銆?/p>

-Xverify:none - 姝?#23534;鍏冲叧闂璊ava瀛楄妭鐮侀獙璇?#38171;?#28000;庤屽?#29362;揩浜?#32491;昏?#21613;叆鐨勯?#25652;?#38171;屽苟浣?#23536;楀湪浠?#28051;?#26976;?#29831;佺洰鐨勮?#37722;姩鐨勮繃绋?#28051;?#37827;?#38343;瑁呭叆绫?#37510;傛寮鍏崇缉鐭?#27996;?#37722;姩?#26882;闂?#38171;屽洜姝病鏈?#37918;?#37922;变笉浣?#37922;?#28729;?#37510;?

-Xms24m - 姝?#29825;?#32515;?#37816;囩 Java 铏氭嫙鏈?#28751;?#37711;?#37714;?#28654;嬪爢澶?#28751;?#29825;?#32515;?#28051;?24 MB銆傞?#26473;?#37816;囩 JVM 鏈鍒?#25652;?#37714;嗛厤缁欏爢鐨?#37712;?#28699;樻暟閲?#38171;?#37721;?#28000;?#28003;?JVM ?#31497;蹇呭湪 IDE ?#23856;鐢?#26440;?#28598;?#37712;?#28699;樻椂澧?#37716;犲爢澶?#28751;?#37510;?

-Xmx96m - 姝?#29825;?#32515;?#37816;囧畾 Java 铏氭嫙鏈?#25652;?#28725;瑰爢浣?#37922;?#37928;勬渶澶?#37712;?#28699;樻暟閲?#37510;?#28051;?#23005;暟閲?#29825;?#32515;?#28051;婇檺琛?#32448;?Java 杩涚娑?#38000;?#37928;?#37712;?#28699;樻暟閲忎笉寰楄秴杩?#37721;?#37922;?#37928;勭墿鐞?#37712;?#28699;樻暟閲?#37510;?#28725;?#27996;庡叿鏈?#37831;?#28598;?#37712;?#28699;?#37928;勭?#33636;粺鍙?#28000;?#28583;?#37716;?#23005;?#38340;?#37714;?#38171;?6 MB 璁?#32515;?#37832;夊姪浜?#32429;?#28103;?IDE ?#28266;鍐?#28699;?#38322;?#28051;?128MB ?#22476; 256MB 鐨勭?#33636;粺涓婅兘澶?#37721;?#38344;犲湴鎵?#29723;屾搷浣?#37510;?#23049;剰锛氫笉瑕佸皢璇?#37706;?#29825;?#32515;?#28051;?#37818;?#26473;?#37812;?#28598;?#27996;?#32495;荤粺鐨勭墿鐞?#37712;?#28699;?#38322;?#38171;屽惁鍒?#28751;嗗湪涓?#29781;佸洖鏀?#26473;?#32459;?#28051;?#28725;艰嚧棰戠箒鐨勪氦?#23858;鎿?#28003;?#37510;?

-XX:PermSize=20m - 姝?JVM 寮鍏充笉浠呭姛?#20824;鏇?#28051;?#23534;?#28598;?#38171;岃?#28051;旇兘澶熺缉鐭?#37722;姩?#26882;闂?#37510;?#29831;?#29825;?#32515;?#37922;?#27996;庤皟鏁?#37712;?#28699;?姘?#28052;呭?#21700;煙"锛?#32491;?#28103;?#28699;樺湪璇?#37718;哄煙涓?#38171;?#37928;?#28598;?#28751;?#37510;?#37733;?#23005;?#37812;戜滑鍚?JVM 鎻愮瀹?#28751;?#38343;瑕?#37928;?#37712;?#28699;?#38322;?#37510;?#29831;?#29825;?#32515;?#23057;堥櫎浜?#29825;?#28598;?#32495;荤粺鍚姩杩?#32459;?#28051;?#37928;?#28051;?#29781;佸?#20904;溇鏀堕?#21973;簨浠?#37510;係unONE Studio 鎴栧叾瀹?#37718;呭惈鏇?#28598;氭鍧?#37928;?IDE 鐨?#37922;?#37812;?#37721;兘甯?#37832;?#28751;?#29831;暟鍊?#29825;?#32515;?#23536;?#37831;撮珮銆?
涓嬮潰鍒楀嚭浜?#37711;?#28729;?#28051;浜?#37721;兘瀵?ECLIPSE ?#28266;鏌愪?#28058;?#33636;粺锛堜笉鏄墍鏈?#32495;荤粺锛?#28051;?#37928;勬?#38003;戒骇鐢?#26462;诲井鎴?#37828;?#37828;?#35120;卞搷鐨?JVM 寮鍏?#37510;?#28751;界浣?#37922;?#28729;冧滑?#32048;?#39559;鐢?#28051;?#30078;鐨?#35120;卞搷锛?#28003;?#28000;?#37706;?#23536;?#28051;璇?#37510;?

-XX:CompileThreshold=100 - 姝?#23534;鍏冲皢闄?#28003;?#37722;姩閫?#25652;?#38171;屽師鍥?#37828;?#28051;庝笉浣?#37922;?#23005;?#23534;鍏崇浉姣?#38171;孒otSpot ?#20824;澶?#37831;?#36423;?#37734;?#28751;?#37831;?#28598;?#37928;勬?#35268;硶缂?#29831;戜负鏈?#37734;?#28000;?#37934;?#37510;?#37711;剁粨鏋?#37828;?#37819;珮浜?IDE 杩?#29723;屾椂鐨勬兘锛?#26473;?#37828;?#37733;?#28051;?#37831;?#28598;?#37928;?UI 浠?#37934;佸皢琚?#32514;?#29831;戣屼笉鏄?#29722;?#29785;噴銆?#29831;?#37706;?#29723;?#32448;?#37826;规硶?#28266;琚?#32514;?#29831;?#37715;?#36423;?#26916;?#29722;皟鐢?#37928;勬?#26271;銆?

-XX:+UseConcMarkSweepGC -XX:+UseParNewGC - 濡?#37835;滃?#20904;溇鍥?#37824;?#26864;戠箒涓?#37826;?#38171;?#37714;?#29831;峰皾璇?#28003;?#37922;?#26473;欎簺寮鍏?#37510;傛寮鍏冲?#33392;嚧 JVM 瀵?#28051;?#29781;佸?#20904;溇鍥?#37824;朵簨浠?#38171;?#28641;?#37835;滃湪澶?#28598;勭?#21975;櫒宸?#28003;?#32468;欎笂杩?#29723;?#38171;?#37714;欎篃閫?#37922;?#27996;庢瑕佸洖鏀朵簨浠?#38171;?#28003;?#37922;笉鍚?#37928;勭?#26945;硶锛?#26473;欎?#28058;?#26945;硶?#31497;?#32048;褰卞?#23942;暣?#37340;鍨冨溇鍥?#37824;?#26473;涚銆?#23049;剰锛氱洰鍓?#28751;氫笉纭畾姝?#37824;堕?#21975;櫒鏄?#37819;珮杩?#37828;?#38340;?#28003;庡崟澶勭?#21975;櫒璁?#32480;?#37832;?#37928;勬兘銆?

-XX:+UseParallelGC - 鏌愪簺娴?#29831;曡鏄?#38171;岃?#20914;?#25117;湪鍐?#28699;橀?#23943;疆?#27977;褰?#38009;?#28610;?#37928;?#37719;?#28598;勭?#21975;櫒绯荤粺涓?#38171;?#28003;?#37922;?#23005;?#37733;?#37824;剁?#26945;硶鍙?#28000;?#28751;?#23046;?#29781;佸?#20904;溇鍥?#37824;?#37928;勬?#20346;画?#26882;闂?#37713;?#37719;?#37510;?#23049;剰锛?#26473;?#37828;?#28051;?#37340;鐭涚浘鐨?#38338;?#26864;?#38171;屼?#23338;疄涓婃鍥?#37824;?#37731;?#28051;?#29781;侀?#37922;?#27996;庡叿鏈夊崈鍏?#28699;楄?#20634;爢鐨?#28598;?#28598;勭?#21975;櫒銆?#28751;?#37827;?#37721;?#37922;暟鎹?#29723;?#37828;庡畠瀵?#28051;?#29781;佸?#20904;溇鍥?#37824;?#37928;?#35120;卞搷銆?#23049;剰锛氭鍥?#37824;?#37731;?#28051;?-XX:+UseConcMarkSweepGC 鏄?#27996;?#37826;?#37928;?#37510;?/p>

鎴?#37928;勬満鍣?#37828;?12MB鐨?#37712;?#28699;?br /> 涓嬮潰鏄?#37812;?#37928;別clipse鍚姩鍙傛暟锛歟clipse.exe -vmargs -Xverify:none -Xms64M -Xmx256M -XX:PermSize=20M  -XX:+UseParallelGC

-----

鎴?#37928;?#37922;佃剳鏄?G鍐?#28699;? 鏈?#28051;娆?#37712;?#28699;樹笉瓒?#27996;?.. MyEclipse 灏?#37818;?#38013;?#37812;戜娇鐢?#28051;?#37340;鍚姩鍙傛暟, 鐜板湪鎴?#37928;?#37722;姩鍙傛暟鏄?


eclipse.exe -vmargs -Xverify:none -Xms128M -Xmx512M -XX:PermSize=64M -XX:MaxPermSize=128M -XX:+UseParallelGC



]]>
鏍戠粨鏋勫?#23677;畠鐨?#28051;?#37922;?#37713;芥暟SYS_CONNECT_BY_PATHhttp://www.67529968.com/lingy/archive/2009/09/20/295773.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Sun, 20 Sep 2009 13:32:00 GMThttp://www.67529968.com/lingy/archive/2009/09/20/295773.html 鍏?#27996;?#37837;?#37928;勬櫘閫?#25652;?#37922;?br /> 瀛範浜?#28051;嬭?#27406;釜鍑芥暟, 鐢ORGINDUSTRIES鐨勮鍋?#27996;嗕釜娴?#29831;?
姝?#29999;?#37928;勬?#25117;瀷?#31912;鏋?br /> select lpad(' ',6*(level-1))||industry,indlevel,indid,pindid
from ORGINDUSTRIES
start with indid=1
connect by pindid=prior indid
?#31912;鏋?#37828;?#32448;?#28641;?#28051;?br />                  Indlevel  indid    pindid
        鏈嶈涓?#37832;?#26967;?nbsp;              1             1             0
              鏈嶈               2             2               1
                    濂?#29761;?nbsp;       3             3               2

鍊掑瀷鏍?br /> 涓嬮潰杩欎釜渚?#28699;?#37828;釜”鍊掓暟”鈥?#37706;?#26473;?#37833;?#37928;勬?#25117;瀷?#31912;鏋?br /> select lpad(' ',6*(level-1))||industry,indlevel,indid,pindid
from ORGINDUSTRIES
start with indid=20
connect by indid=prior pindid;
杩?#37828;?#37837;囧?#21977;粨鏋?
                             Indlevel indid    pindid
浜?#37813;?#37832;嶈                      3        20       2
      鏈嶈                    2        2        1
            鏈嶈涓?#37832;?#26967;?nbsp;       1        1        0
?#31912;璁?br /> 鏃?#29825;?#23005;?#37837;戣繕鏄?#37706;?#37837;? 鍏抽敭灏卞湪浜巆onnect by鐨?#37833;?#28000;?
姝?#37837;?  蹇?#26916;?#37828;?nbsp; ‘鐖?#8217;= prior ‘瀛?#8217;
鍊?#37837;?  蹇?#26916;?#37828;?nbsp; ‘瀛?#8217;= prior ‘鐖?#8217;

鏍戝瀷?#31912;鏋?#37928;?#37833;?#28000;?#26473;囨护
閲?#37922;?#37837;戝瀷?#31912;鏋?#37928;?#29831;? 濡?#37835;?#37812;戜滑鎯冲皢鏍戜笂鐨?#28051;?#37340;鍒?#37824;?#37934;?#37818;?  灏?#37714;?#37824;?#37722;庨潰鐨勭粨鏋?#38318;芥姏寮?#37818;? 杩欎釜鍙?#28000;?#28729;?#37916;伴?#26020;紵褰撶劧鍙?#28000;?#37510;?浣?#37828;笉鏄?#37922;where锛?where鏉?#28000;?#37721;兘鍘婚櫎鍗?#28051;鐨?#37833;?#28000;?#37510;?br /> ?#22669;浠?#38171;?杩欑鏍戝瀷鐨勮繃?#25252;鏉?#28000;?#28751;?#38343;瑕?#37716;犲湪connect by涓婇潰銆?br />
娴?#29831;?#28641;?#28051;?#38171;?#37922;?#27996;?#37922;?#37930;?#28729;?#37916;?#28583;?#23011;旇緝璐?#26473;?#28729;?#38340;?#38171;屾墍浠?#37819;?#37715;?#37922;?#28051;婼YS_CONNECT_BY_PATH鍑芥暟鏉?#37828;?#32448;?#28051;?#37916;?#28583;?br />
?#31497;鍔?#28000;?#28003;?#37833;?#28000;?#37928;?#37916;?#28583;?#38171;?br /> select areaname,sys_connect_by_path(areaname,',')
from areas bb
start with areaname='涓?#37733;?#28598;檰'
connect by parentareaid=prior areaid  

?#31912;鏋?#38171;?br /> 1        涓?#37733;?#28598;檰,涓?#37733;?#28598;檰
2        鍖?#27996;?nbsp;       ,涓?#37733;?#28598;檰,鍖?#27996;?br /> 3        鍖?#27996;?nbsp;       ,涓?#37733;?#28598;檰,鍖?#27996;?鍖?#27996;?br /> 4        涓?#37737;庡尯        ,涓?#37733;?#28598;檰,鍖?#27996;?涓?#37737;庡尯
5        瑗?#37737;庡尯        ,涓?#37733;?#28598;檰,鍖?#27996;?瑗?#37737;庡尯
22        骞?#28051;?nbsp;       ,涓?#37733;?#28598;檰,骞?#28051;?br /> 23        骞?#23480;?nbsp;       ,涓?#37733;?#28598;檰,骞?#28051;?骞?#23480;?br /> 24        姹曞熬        ,涓?#37733;?#28598;檰,骞?#28051;?姹曞熬
25        ?#30086;闃?nbsp;       ,涓?#37733;?#28598;檰,骞?#28051;??#30086;闃?br /> 46        涓?#23092;?nbsp;       ,涓?#37733;?#28598;檰,涓?#23092;?br /> 47        涓?#23092;?nbsp;       ,涓?#37733;?#28598;檰,涓?#23092;?涓?#23092;?br /> 48        榛?#23092;?#37718;?nbsp;       ,涓?#37733;?#28598;檰,涓?#23092;?榛?#23092;?#37718;?br /> 49        闂?#37718;楀尯        ,涓?#37733;?#28598;檰,涓?#23092;?闂?#37718;楀尯


鍔?#27996;where杩囨护鏉?#28000;?#37928;凷QL:
select areaname,sys_connect_by_path(areaname,',')
from areas bb
where bb.areaid>861000
start with areaname='涓?#37733;?#28598;檰'
connect by parentareaid=prior areaid

?#31912;鏋?#28051;?#38171;?br /> 2        鍖?#27996;?nbsp;       ,涓?#37733;?#28598;檰,鍖?#27996;?br /> 3        鍖?#27996;?nbsp;       ,涓?#37733;?#28598;檰,鍖?#27996;?鍖?#27996;?br /> 4        涓?#37737;庡尯        ,涓?#37733;?#28598;檰,鍖?#27996;?涓?#37737;庡尯
5        瑗?#37737;庡尯        ,涓?#37733;?#28598;檰,鍖?#27996;?瑗?#37737;庡尯
22        骞?#28051;?nbsp;       ,涓?#37733;?#28598;檰,骞?#28051;?br /> 23        骞?#23480;?nbsp;       ,涓?#37733;?#28598;檰,骞?#28051;?骞?#23480;?br /> 24        姹曞熬        ,涓?#37733;?#28598;檰,骞?#28051;?姹曞熬
25        ?#30086;闃?nbsp;       ,涓?#37733;?#28598;檰,骞?#28051;??#30086;闃?br /> 46        涓?#23092;?nbsp;       ,涓?#37733;?#28598;檰,涓?#23092;?br /> 47        涓?#23092;?nbsp;       ,涓?#37733;?#28598;檰,涓?#23092;?涓?#23092;?br /> 48        榛?#23092;?#37718;?nbsp;       ,涓?#37733;?#28598;檰,涓?#23092;?榛?#23092;?#37718;?br /> 49        闂?#37718;楀尯        ,涓?#37733;?#28598;檰,涓?#23092;?闂?#37718;楀尯

?#31912;璁?#38171;氬幓鎺?#27996;?#8220;1        涓?#37733;?#28598;檰,涓?#37733;?#28598;檰”?#26271;鎹?br />
鍔?#27996;哻onnect by鐨勮繃?#25252;鏉?#28000;?#38171;?br /> select areaname,sys_connect_by_path(areaname,',')
from areas bb
where bb.areaid>861000
start with areaname='涓?#37733;?#28598;檰'
connect by parentareaid=prior areaid  and areaname<>'骞?#28051;?

?#31912;鏋?#28051;?#38171;?br /> 2        鍖?#27996;?nbsp;       ,涓?#37733;?#28598;檰,鍖?#27996;?br /> 3        鍖?#27996;?nbsp;       ,涓?#37733;?#28598;檰,鍖?#27996;?鍖?#27996;?br /> 4        涓?#37737;庡尯        ,涓?#37733;?#28598;檰,鍖?#27996;?涓?#37737;庡尯
5        瑗?#37737;庡尯        ,涓?#37733;?#28598;檰,鍖?#27996;?瑗?#37737;庡尯
46        涓?#23092;?nbsp;       ,涓?#37733;?#28598;檰,涓?#23092;?br /> 47        涓?#23092;?nbsp;       ,涓?#37733;?#28598;檰,涓?#23092;?涓?#23092;?br /> 48        榛?#23092;?#37718;?nbsp;       ,涓?#37733;?#28598;檰,涓?#23092;?榛?#23092;?#37718;?br /> 49        闂?#37718;楀尯        ,涓?#37733;?#28598;檰,涓?#23092;?闂?#37718;楀尯

?#31912;璁?#38171;氬幓鎺?#27996;嗘暣?#37340;骞?#28051;?#37928;?#37714;?#37824;?#38171;?nbsp; ?#28266;?#31912;鏋滈泦涓?#37721;?#37832;夊寳浜拰涓?#23092;?br />

SYS_CONNECT_BY_PATH鍑芥暟
閲?#37922;SYS_CONNECT_BY_PATH鍑芥暟涓?

select industry,sys_connect_by_path(industry,'/')
from ORGINDUSTRIES
start with indid=3
connect by indid=prior pindid;

?#31912;鏋?#28051;?
濂?#29761;?nbsp;              /濂?#29761;?br /> 鏈嶈               /濂?#29761;?鏈嶈
鏈嶈涓?#37832;?#26967;?nbsp;           /濂?#29761;?鏈嶈/鏈嶈涓?#37832;?#26967;?br />
杩?#37837;?#37928;?#29831;? 灏?#37721;?#28000;?#28729;?#37916;? 鏍戠粨鏋?#37928;勭粨鏋滈泦鐨?#37719;曡?#23678;嫾鎺?

鎴戜滑鍙?#38343;瑕?#37721;?#37832;澶?#37928;?#28699;?#23048;?#28751;監K浜?br />
娴?#29831;?#28641;?#28051;?#38171;?br />
select max(sys_connect_by_path(industry,'/'))
from ORGINDUSTRIES
start with indid=3
connect by indid=prior pindid;

?#31912;鏋?#28051;?#38171;?br /> /濂?#29761;?鏈嶈/鏈嶈涓?#37832;?#26967;?br />

澶?#37833;?#37928;勬?#25117;瀷?#31912;鏋?#37413;?#37413;?#28598;?#37714;楀彉鍗?#37714;?br /> 鏍戝瀷?#31912;鏋勪篃鍒?#37719;?#37837;戝拰澶?#37837;?鎴?#37928;勭鍛?瀹?#38340;?#28051;?#28751;?#37828;?#37816;囧崟鏀拰澶氭敮)
瀵?#27996;?#28051;嬮潰鐨勮繖绉?#37807;呭喌锛?鎴戜滑蹇?#26916;?#29781;?#37835;勯?#37928;勬爲灏?#28766;炰?#24225;崟鏀?#37837;?#37510;?br /> ?#24107;濮?#37916;?#28583;?br /> 鐜?#28583;?#28641;?#28051;?#38171;?br /> select * from test锛?br />
?#31912;鏋?#28051;?#38171;?br /> 1        n1
1        n2
1        n3
1        n4
1        n5
3        t1
3        t2
3        t3
3        t4
3        t5
3        t6
2        m1

閫?#37837;?br /> 鑴?#37832;?#28641;?#28051;?#38171;?br /> select no,q,
       no+row_number() over( order by no) rn,
       row_number() over(partition by no order by no) rn1
from test

?#31912;鏋?#28641;?#28051;?#38171;?br /> No  Q  RN RN1
1        n1        2        1
1        n2        3        2
1        n3        4        3
1        n4        5        4
1        n5        6        5
2        m1        8        1
3        t1        10        1
3        t2        11        2
3        t3        12        3
3        t4        13        4
3        t5        14        5
3        t6        15        6

姣?#37714;?#37928;勭洰鐨?#37828;?#38171;?br /> RN1鍒?#28051;?#29781;?#37928;勭洰鐨?#37828;?#37714;?#32513;?#38171;?鎸夌収value鍊?#8216;1’锛?#37812;戜滑鍙?#28000;start with浣?#37922;?#28729;?#37510;?br />
RN鍒?#28051;?#29781;?#37922;?#37833;?#37707;歝onnect by浣?#37922;?#37510;?瀹?#38340;?#28051;?#28729;?#28751;?#37828;?#37812;戜滑瑕?#37928;勬爲銆?br /> 绗?#28051;?#37340;鏀?#38171;?2锛?锛?锛?锛?
绗?#27996;屼釜鏀?#38171;?8
绗?#28051;変釜鏀?#38171;?10锛?1锛?2锛?3锛?4锛?5

涓?#38338;?#28051;?#28000;涔?#29781;?#37826;?#37818;?#38171;?,9  ?#27952;鐨勫氨鏄?#28051;?#27996;嗗尯鍒?#23011;忎釜鍒?#37824;?#37510;??#22476;鍚庨潰?#28229;鍏蜂綋鐨凷QL锛屽氨鏄?#37927;?#26473;?#38322;?#37928;?#29831;存硶浜?#37510;?br />
鏉鎵嬮攺
鏃劧鎴戜滑鏈?#27996;?#37837;?#38171;?灏?#37721;?#28000;?#28003;?#37922;?#37837;戝瀷鍑芥暟SYS_CONNECT_BY_PATH?#25328;connect by鍟?#38171;?#37833;?#37815;?#37818;?#37812;戜滑?#22669;闇瑕?#37928;?#28598;?#37714;楀?#37510;?br />
鑴?#37832;?#28641;?#28051;?#38171;?br /> select no,sys_connect_by_path(q,',')
from (
select no,q,
       no+row_number() over( order by no) rn,
       row_number() over(partition by no order by no) rn1
from test
)
start with rn1=1
connect by rn-1=prior rn

?#31912;鏋?#28051;?#38171;?br /> 1        ,n1
1        ,n1,n2
1        ,n1,n2,n3
1        ,n1,n2,n3,n4
1        ,n1,n2,n3,n4,n5
2        ,m1
3        ,t1
3        ,t1,t2
3        ,t1,t2,t3
3        ,t1,t2,t3,t4
3        ,t1,t2,t3,t4,t5
3        ,t1,t2,t3,t4,t5,t6

缁?#37835;?#23005;?#37731;?br /> 鏈缁?#37812;戜滑瑕?#37928;?#37706;?#38171;?#37828;?#37719;?#37714;楀?#38171;?鍏?#28729;?#37807;?#37807;?#38171;?涔?#28751;?#37828;?#37832;闀?#37928;?#28051;琛屽挴銆?閭?#28052;?#28751;卞鍔炰簡銆?鎴戜滑鐩?#37818;GROUP BY 锛岀劧鍚?#37721;MAX鍊?#37510;?br /> 鑴?#37832;?#28641;?#28051;?#38171;?br /> select no,max(sys_connect_by_path(q,','))
from (
select no,q,
       no+row_number() over( order by no) rn,
       row_number() over(partition by no order by no) rn1
from test
)
start with rn1=1
connect by rn-1=prior rn
group by no

?#31912;鏋?#28051;?#38171;?br /> 1        ,n1,n2,n3,n4,n5
2        ,m1
3        ,t1,t2,t3,t4,t5,t6

濡?#37835;?#29785;夊?#26944;墠?#28528;鐨?#8216;锛?#8217;?#31497;濂界湅锛?#37721;?#28000;?#28003;?#37922;ltrim鍘?#37818;?#37510;?鎴?#38000;?#37922;substr涔?#37721;?#28000;?#37510;?br /> 濡?#28051;?#38171;?br /> ltrim(max(sys_connect_by_path(q,',')),',')
鎴?#38000;?br /> substr(max(sys_connect_by_path(q,',')),2)


]]>
vim ?#22476;鎸囧畾琛?:3305http://www.67529968.com/lingy/archive/2009/09/02/293577.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Wed, 02 Sep 2009 04:28:00 GMThttp://www.67529968.com/lingy/archive/2009/09/02/293577.html :number
eg:
:3305

]]>
Vim?#29025;鎵炬搷浣?/title><link>http://www.67529968.com/lingy/archive/2009/09/02/293576.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Wed, 02 Sep 2009 04:25:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2009/09/02/293576.html</guid><description><![CDATA[<p> </p> <div class="cnt" id="blog_text"><font size="4">" 鎼滅储<br /> /joe/e : 璁?#32515;厜鏍囧埌鍖归厤"joe"鐨勬湯灏?br /> /joe/e+1 : 璁?#32515;厜鏍囧埌鍖归厤"joe"鐨勬湯灏?#37712;?#37722;庣涓浣?br /> /joe/s-2 : 璁?#32515;厜鏍囧埌鍖归厤"joe“鐨?#23534;澶?#37712;?#37715;嶇涓?#28003;?br /> /^joe.*fred.*bill/ : 鍖归厤浠?j'寮澶?#28051;?joe"?#22476;"fred"?#22476;"bill"涔?#38338;?#38007;冲?#25118;湁涓?#37340;瀛?#32471;?br /> /^[A-J]\+/ : 鎼滅储'A'?#22476;’J‘閲?#28598;?#28051;?#23046;?#28000;?#28051;?#37928;?#23534;澶?#29723;?br /> /begin\_.*end : 澶?#29723;屽尮?#21412;<br /> /fred\_s*joe/i : 鍙?#28000;?#37828;?#28000;?#28003;曠?#34425;櫧瀛?#32471;?#37718;呮嫭\n,\t绛?#32475;?br /> /fred\|joe : 鎼滅储fred鎴?#38000;卝oe<br /> /.*fred\&.*joe : 鎼滅储鍚屾椂鍖呮嫭fred璺焜oe鐨勮<br /> /\<fred\>/i : 鎼滅储?#23277;绔?#37928;?#37719;?#29831;峟red<br /> /\<\d\d\d\d\> : 鎼滅储?#23277;绔?#37928;?浣嶆暟瀛?br /> /\D\d\d\d\d\D : 鎼滅储6浣?#28699;?#32471;?#28051;?#28051;?#38338;?浣嶆暟瀛楀墠鍚?#28051;?#28003;嶄笉?#20824;涓烘暟瀛?br /> /\<\d\{4}\> : 鍚?\<\d\d\d\d\><br /> " ?#29025;鎵剧琛?br /> /^\n\{3} : 鍖归厤涓?#26473;?#32513;?#37928;勭琛?br /> " 浣?#37922;?#23005;?#37714;?#29723;?#26440;?#23534;?#32513;勬煡鎵?br /> /\(fred\).*\(joe\).*\2.*\1<br /> " 姝?#37714;?#29723;?#26440;?#23534;?#38322;?#28598;?br /> /^\([^,]*,\)\{8}<br /> " visual searching<br /> :vmap // y/<C-R>"<CR> : visually妯?#23534;?#28051;?#37928;勯敭鐩?#37828;犲皠锛屾妸//鏄犲?#21228;垚鍖归厤褰撳墠閫?#28051;?#37928;勬枃鏈?br /> :vmap <silent> // y/<C-R>=escape(@", '\\/.*$^~[]')<CR><CR> : 鍖呮嫭绌虹櫧瀛?#32471;?br /> " \zs ?#25328; \ze 鍖归厤?#24107; :h /\zs<br /> /<\zs[^>]*\ze> : 鍖归厤灏栨嫭鍙蜂腑鐨?#37712;呭<br /> " 闆?#28729;?#25652;?#37718;归厤 :h /\@=<br /> /<\@<=[^>]*>\@= : search for tag contents, ignoring chevrons<br /> /<\@<=\_[^>]*>\@= : search for tags across possible multiple lines<br /> " 澶?#29723;屾煡鎵?\_ 鐨勬剰鎬?#37828;?#37718;呮嫭?#23858;琛?#32471;?br /> /<!--\_p\{-}--> : 鍖归厤<!--寮濮嬪埌-->?#31912;灏?#37928;勬墍鏈?#37712;呭<br /> /fred\_s*joe/i : 鍖归厤fred寮濮嬪埌joe锛屼箣闂?#28051;?#30078;寰?#37828;?#32460;虹櫧瀛?#32471;?br /> /bugs\(\_.\)*bunny : 鍖?#38320;嶆墍鏈塨ugs?#22476;bunny鐨?#28699;?#32471;?#28051;?br /> :h \_ : help<br /> " ?#29025;鎵?#37713;芥暟澹?#37828;?#38171;宯map涓簄ormal妯?#23534;?#28051;?#37928;勯敭鐩?#37828;犲皠<br /> :nmap gx yiw/^\(sub\<bar>function\)\s\+<C-R>"<CR><br /> " ?#29025;鎵?#28598;氫釜鏂?#28000;?br /> :bufdo /searchstr/ : ?#28266;澶氫釜鏂?#28000;剁紦鍐?#37718;?#38322;?#37813;?#29723;屾煡鎵?br /> " 鏇?#28610;?#37928;?#28598;?#37826;?#28000;舵煡鎵惧畾浣?#37826;规硶<br /> :bufdo %s/searchstr/&/gic : ?#28266;澶氫釜鏂?#28000;剁紦鍐?#37718;?#38322;屾煡鎵?#38171;?#37816;?#28051;n鍋?#23005;?br /> " 鎬?#37837;蜂笉浣?#37922;?/ 鏉煡鎵剧綉?#28483;<br /> ?</font><a href="http://www.vim.org/" target="_blank"><font size="4">http://www.vim.org/</font></a><font size="4"> : 鍚?#37722;庢煡鎵?br /> " ?#29025;鎵?#37816;囧畾瀛?#32471;?#28000;?#28598;?#37928;?#28699;?#32471;?#28051;?br /> /\c\v([^aeiou]&\a){4} : ?#29025;鎵??#37340;杈呴瀛?#23011;?br /> ----------------------------------------<br /> #鏇挎崲<br /> :%s/fred/joe/igc : 鏅?#38315;?#37831;挎崲鍛戒护<br /> :%s/\r//g : 鍒犻櫎 DOS 鐨勬崲琛?#32471;?^M<br /> " 浣?#37928;勬枃鏈?#37826;?#28000;?#37828;惁涔?#28051;?#37711;?#32495;?#37928;勬帓鎴?#28051;琛岋紵浣?#37922;?#28641;?#28051;?#37723;戒护<br /> :%s/\r/\r/g : ?#27974;?#23858; DOS 鍥?#26462;?#32471;?^M 涓虹?#29112;鐨勫洖杞?#32471;?br /> :%s= *$== : 鍒犻櫎琛屽?#21095;?#34425;櫧<br /> :%s= \+$== : 鍚?#28051;?br /> :%s#\s*\r\?$## : 鍒犻櫎灏?#38318;?#32460;虹櫧?#25328;dos?#23858;琛?#32471;?br /> :%s#\s*\r*$## : 鍚?#28051;?br /> " 鍒犻櫎绌?#29723;?br /> :%s/^\n\{3}// : 鍒犻櫎杩?#32513;??#37340;绌?#29723;?br /> :%s/^\n\+/\r/ : 鍘嬬缉绌?#29723;?#38171;?#28598;氫釜鏇挎崲涓?#28051;?#37340;<br /> %s#<[^>]\+>##g : 鍒犻櫎html鐨則ag閮?#37714;?br /> " IF YOU ONLY WANT TO KNOW ONE THING<br /> :'a,'bg/fred/s/dick/joe/igc : 闈?#29999;?#37832;?#37922;?br /> # 璇戦噴锛?'a,''b鎸囧畾涓?#37340;鑼冨洿锛歮ark a ~ mark b<br /> # g//鐢?#28051;?#37340;姝?#37714;?#29723;?#26440;?#23534;?#37816;囧嚭浜?#26473;?#29723;屾搷浣?#37928;勮?#23677;繀椤?#37721;?#28000;?#29722;fred鍖归厤<br /> # ?#28229;鍚庨潰锛実//鏄?#28051;?#37340;鍏?#28766;鏄?#32448;?#37723;戒护<br /> # s/dick/joe/igc鍒?#28725;?#27996;?#26473;欎簺婊?#29906;?#37833;?#28000;?#37928;勮杩?#29723;?#37831;挎崲<br /> " 澶?#37714;?#37714;?br /> :%s= [^ ]\+$=&&= : 澶?#37714;?#37832;鍚?#28051;鍒?br /> :%s= \f\+$=&&= : 涓鏍?br /> :%s= \S\+$=&& : 鏅?#38171;?#26473;?#28051;鏍?#38171;?br /> " 璁板繂锛?#37721;?#37722;?#23534;?#37922;?#38171;?br /> :s/\(.*\):\(.*\)/\2 : \1/ : 灏?#28051;釜瀛?#23048;?#26864;?#37706;?br /> :%s/^\(.*\)\n\1$/\1/ : 鍒犻櫎閲?#28598;?#29723;?br /> " 闈?#29840;?#28640;?#37718;归厤 \{-}<br /> :%s/^.\{-}pdf/new.pdf/ : 鍒犻櫎绗?#28051;?#37340;pdf<br /> " use of optional atom \?<br /> :%s#\<[zy]\?tbl_[a-z_]\+\>#\L&#gc : lowercase with optional leading characters<br /> " 璺?#29906;?#28751;?#38322;?#28598;?#37928;勮<br /> :%s/<!--\_.\{-}-->// : 鍒犻櫎澶?#29723;?#23049;噴<br /> :help /\{-} : ?#29025;鐪嬮潪璐?#28640;?#37718;归厤鐨?#37831;?#28598;?#29999;?#37716;?br /> " 浣?#37922;?#28725;?#28699;?#37731;?#37831;挎崲<br /> :s/fred/<c-r>a/g : 灏唂red鏇挎崲涓?#28725;?#28699;?#37731;a閲?#37928;?#37712;呭<br /> :s/fred/<c-r>asome_text<c-r>s/g<br /> :s/fred/\=@a/g : better alternative as register not displayed<br /> " ?#28266;涓琛岄噷鍐?#28598;氱鍛戒护<br /> :%s/\f\+\.gif\>/\r&\r/g | v/\.gif$/d | %s/gif/jpg/<br /> :%s/a/but/gie|:update|:next : 褰?#28003;?#37922;?@: 鏉?#38322;?#28598;?br /> " 鎴?#26473;愮畻<br /> :%s/suck\|buck/loopy/gc : 鏇挎崲suck鎴?#38000;卋uck锛?#26473;?#38322;寍?#31497;鏄?#32480;?#38316;?#38171;?br /> " ?#30367;鐢vim鍑芥暟<br /> :s/__date__/\=strftime("%c")/ : 灏哶_date__鏇挎崲鎴?#35120;撳墠鏃?#37832;?#38171;?#28003;?#37922;strftime鍑芥暟<br /> " 澶勭悊鍒?#38171;?#37831;挎崲?#22669;鏈夊湪绗?#28051;?#37714;?#28051;?#37928;剆tr1<br /> :%s:\(\(\w\+\s\+\)\{2}\)str1:\1str2:<br /> " 浜崲绗?#28051;鍒楄窡绗洓鍒?br /> :%s:\(\w\+\)\(.*\s\+\)\(\w\+\)$:\3\2\1:<br /> " 杩囨护form涓?#37928;?#37712;呭?#35268;?#24807;湪瀵?#28699;?#37731;?#38322;?br /> :redir @*|sil exec 'g#<\(input\|select\|textarea\|/\=form\)\>#p'|redir END<br /> :nmap ,z :redir @*<Bar>sil exec 'g@<\(input\<Bar>select\<Bar>textarea\<Bar><br /> /\=form\)\>@p'<Bar>redir END<CR><br /> " 涓?#28003;?#28000;?#28051;?#37928;勬暟瀛楀噺涓?#38171;?#29999;?#26473;?#28003;?#37510;?#26473;欎釜鍛戒护鎸?#37832;夎叮锛?br /> :%s/\d\+/\=(submatch(0)-3)/<br /> " 鍖呭惈loc鎴?#38000;協unctions鐨勮涓?#37928;勬暟瀛楀姞6<br /> :g/loc\|function/s/\d/\=submatch(0)+6/<br /> " 姣?#28051;婇潰鏇?#28610;?#37928;勬?#35268;硶<br /> :%s#txtdev\zs\d#\=submatch(0)+1#g<br /> :h /\zs ?#29025;?#28229;甯?#37716;?br /> " 鍓嶇紑涓篻g鐨勬暟瀛楀姞6<br /> :%s/\(gg\)\@<=\d\+/\=submatch(0)+6/<br /> :h zero-width ?#29025;?#28229;甯?#37716;?br /> " 鏇挎崲涓?#37340;鐗瑰畾瀛?#32471;?#28051;?#28051;烘暟瀛?br /> :let i=10 | 'a,'bg/Abc/s/yy/\=i/ |let i=i+1 # 灏唝y?#27974;?#23858;鎴?0锛?1锛?2绛?#32475;?br /> " 姣?#28051;婇潰鐨?#37831;寸簿纭?br /> :let i=10 | 'a,'bg/Abc/s/xx\zsyy\ze/\=i/ |let i=i+1 # 灏唜xyy ?#27974;?#23858;鎴?xx11,xx12,<br /> xx13<br /> " find replacement text, put in memory, then use \zs to simplify substitute<br /> :%s/"\([^.]\+\).*\zsxx/\1/<br /> " Pull word under cursor into LHS of a substitute<br /> :nmap <leader>z :%s#\<<c-r>=expand("<cword>")<cr>\>#<br /> " Pull Visually Highlighted text into LHS of a substitute<br /> :vmap <leader>z :<C-U>%s/\<<c-r>*\>/<br /> ----------------------------------------<br /> " all following performing similar task, substitute within substitution<br /> " Multiple single character substitution in a portion of line only<br /> :%s,\(all/.*\)\@<=/,_,g : replace all / with _ AFTER "all/"<br /> " Same thing<br /> :s#all/\zs.*#\=substitute(submatch(0), '/', '_', 'g')#<br /> " Substitute by splitting line, then re-joining<br /> :s#all/#&^M#|s#/#_#g|-j!<br /> " Substitute inside substitute<br /> :%s/.*/\='cp '.submatch(0).' all/'.substitute(submatch(0),'/','_','g')/<br /> ----------------------------------------<br /> " 鍏?#28766;鏄?#32448;?#37723;戒护<br /> :g/gladiolli/# : ?#29025;鎵?#39582;?#37828;?#32448;?#37718;归厤鐨勮鍙?br /> :g/fred.*joe.*dick/ : 鏄?#32448;烘墍鏈?#37722;?#37832;?fred,joe & dick鐨勮<br /> :g/\<fred\>/ : 鏄?#32448;?#37719;?#28051;鍗?#29831;峟red<br /> :g/^\s*$/d : 鍒犻櫎?#22669;鏈夌琛?br /> :g!/^dd/d : 鍒犻櫎?#31497;鍚?#28699;?#32471;?#28051;?'dd''鐨勮<br /> :v/^dd/d : 鍚?#28051;?br /> :g/fred/,/joe/d : 鍒犻櫎?#22669;鏈?#37928;?#28000;巉red?#22476;joe<br /> :g/-------/.-10,.d : 浠?------涓?#37837;?#29825;?#37714;犻櫎涔嬪墠鐨?0琛?br /> :g/{/ ,/}/- s/\n\+/\r/g : 鍒犻櫎 {...}涔?#38338;?#37928;勭琛?br /> :v/\S/d : Delete empty lines (both types)<br /> :v/./,/./-j : 鍘嬬缉绌?#29723;?br /> :g/^$/,/./-j : 鍚?#28051;?br /> :g/<input\|<form/p : 鎴?#26473;愮畻<br /> :g/^/put_ : 鍙?#37706;?#29723;屽 (pu = put)<br /> :g/^/m0 : 棰?#37706;?#37826;?#28000;?(m = move)<br /> :'a,'bg/^/m'b : 棰?#37706;?#38315;?#28051;?#37928;?a ?#22476; b<br /> :g/^/t. : 閲?#28598;?#29723;?br /> :g/fred/t$ : 鎷?#29840;?#29723;?#28000;巉red?#22476;?#31912;灏?br /> :g/stage/t'a : 鎷?#29840;?#29723;?#28000;巗tage ?#22476; marker a锛坅涓?#37837;?#29825;?#37928;?#28003;嶇疆锛?br /> :g/\(^I[^^I]*\)\{80}/d : 鍒犻櫎鏈灏?#37718;呭惈80?#37340;tab鐨勮<br /> " perform a substitute on every other line<br /> :g/^/ if line('.')%2|s/^/zz /<br /> " match all lines containing "somestr" between markers a & b<br /> " copy after line containing "otherstr"<br /> :'a,'bg/somestr/co/otherstr/ : co(py) or mo(ve)<br /> " as above but also do a substitution<br /> :'a,'bg/str1/s/str1/&&&/|mo/str2/<br /> :%norm jdd : 闅旇鍒犻櫎<br /> " 澧?#37716;犳暟瀛?(?#25965;?#21446; <c-a>)<br /> :.,$g/^\d/exe "norm! \<c-a>": 澧?#37716;?#28000;庡?#25779;墠琛?#26851;栧埌?#31912;灏?#37928;勬暟瀛?br /> :'a,'bg/\d\+/norm! ^A : 澧?#37716;犳暟瀛?br /> " 淇?#28699;?#37711;?#28766;鍛戒护鐨勭粨鏋?(娉?#37808;忓繀椤?#28003;?#37922;?#23075;诲姞妯?#23534;? 浣?#38343;瑕?#28003;?#37922;?qaq 娓呯瀵?#28699;?#37731;a.<br /> "save results to a register/paste buffer 瀛樺偍?#31912;鏋滃埌 瀵?#28699;?#37731;?绮樿创 ?#22476; a<br /> :g/fred/y A : 娣诲?#29371;厤澶?#29723;屽埌瀵?#28699;?#37731;埌 a<br /> :g/fred/y A | :let @*=@a : 鏀惧叆澶?#37714;剁紦鍐?#37718;?br /> :let @a=''|g/Barratt/y A |:let @*=@a<br /> :'a,'b g/^Error/ . w >> errors.txt<br /> " 澶?#37714;?#23011;?#28051;琛?#38171;岀劧鍚庡湪澶?#37714;?#37713;?#37833;?#37928;勬瘡涓琛?#28051;?#28186;?#37716;?#28051;?#28051;?#37340; print '澶?#37714;?#37713;?#37833;?#37928;?#37712;呭'<br /> :g/./yank|put|-1s/'/"/g|s/.*/Print '&'/<br /> " 鐢?#37826;?#28000;?#28051;?#37928;?#37712;呭鏇挎崲瀛?#32471;?#28051;?#38171;?d 琛?#32448;?#37714;犻櫎“鏍?#29825;?#8221;<br /> :g/^MARK$/r tmp.ex | -d<br /> " display prettily<br /> :g/<pattern>/z#.5 : display with context<br /> :g/<pattern>/z#.5|echo "==========" : display beautifully<br /> " Combining g// with normal mode commands<br /> :g/|/norm 2f|r* : replace 2nd | with a star<br /> "send output of previous global command to a new window<br /> :nmap <F3> :redir @a<CR>:g//<CR>:redir END<CR>:new<CR>:put! a<CR><CR><br /> ----------------------------------------<br /> " 鍏?#28766;鍛戒护?#25328;鏇挎崲鍛戒护鑱斿 (寮?#28598;?#37928;勭紪杈戣兘鍔?<br /> :'a,'bg/fred/s/joe/susan/gic : 鍙?#28000;?#28003;?#37922;?#37721;?#37722;?#23534;?#37922;?#37833;?#37718;归厤<br /> :g/fred/,/joe/s/fred/joe/gic : non-line based (ultra)<br /> ----------------------------------------<br /> " ?#21403;鎵fred锛岀劧鍚庢壘joe<br /> :/fred/;/joe/-2,/sid/+3s/sally/alley/gIC<br /> ----------------------------------------<br /> " create a new file for each line of file eg 1.txt,2.txt,3,txt etc<br /> :g/^/exe ".w ".line(".").".txt"<br /> ----------------------------------------<br /> " Absolutely essential<br /> ----------------------------------------<br /> * # g* g# : ?#29025;鎵?#35120;撳墠?#21404;鏍?#28051;?#37928;?#37719;?#29831;?#38171;?#37719;曚釜鍗?#29831;?#38171;?(<cword>) (鍚?#37715;?鍚?#37722;?<br /> % : 鍖?#38320;嶆嫭鍙?{}[]()<br /> . : 閲?#28598;?#28051;婃鎿?#28003;?br /> @: : 閲?#28598;?#28051;婃鐨?#37723;戒护<br /> matchit.vim : 閫??#20824;鍖归厤 <script> <?php绛?#37837;?#29825;?br /> <C-N><C-P> : 鎻掑叆妯?#23534;?#28051;嬭嚜?#23017;瀹?#37812;愬璇?br /> <C-X><C-L> : 琛岃嚜?#23017;瀹?#37812;?#38171;堣?#21615;骇鏈?#37922;?#38171;?br /> /<C-R><C-W> : ?#22968;鍗曚釜<cword>鍗?#29831;嶆?#24807;叆鎼滅储鎴?#38000;?#37723;戒护琛?br /> /<C-R><C-A> : ?#22968;瀛?#32471;?#28051;?#28051;?#37832;?#37928;?#37719;?#29831;?lt;CWORD>鏀惧叆鎼滅储鎴?#38000;?#37723;戒护琛?br /> :set ignorecase : 蹇界暐澶?#28751;?#37712;?br /> :syntax on : 鎵撳紑璇硶?#29678;浜?Perl,HTML,PHP 绛?#32475;?br /> :h regexp<C-D> : 鎸塩trl+d寰楀埌鍖呭惈regexp鐨?#37714;?#29723;?br /> (鎸塼ab鑷姩?#31497;?#32136;)<br /> ----------------------------------------<br /> " 绠鍗曠紪杈?#37831;?#37826;?_vimrc鏂?#28000;?br /> :nmap ,s :source $VIM/_vimrc :鏅?#38315;氭寮?#28051;?#37928;勯敭鐩?#37828;犲皠 ,s鏄犲?#21228;垚鍔?#26462;?#37922;?#37812;风洰褰?#28051;?#37928;?br /> _vimrc鏂?#28000;?br /> :nmap ,v :e $VIM/_vimrc :,v鏄犲?#21228;垚鎵撳紑_vimrc鏂?#28000;?br /> ----------------------------------------<br /> #VISUAL 妯?#23534;?(鏂?#28186;?#28583;?#37716;?HTML 鏍?#32475;?<br /> :vmap sb "zdi<C-R>z<ESC> : ?#28266; VISUALLY妯?#23534;?#28051;嬪皢閫?#28051;?#37928;勬枃鏈?#37715;?#37722;?#37714;?#37714;?#37716;?#28051;?br /> :vmap st "zdi<?= <C-R>z ?><ESC> : 鍔?#28051;?<?= ?><br /> ----------------------------------------<br /> " 娴?#29785;?br /> :Exp(lore) : 娴?#29785;?#37826;?#28000;?br /> :Sex(plore) : 鍒嗗壊绐楀彛娴?#29785;?#37826;?#28000;?br /> :ls : 鏄?#32448;虹紦鍐?#37718;?br /> :cd .. : 璁?#32515;?#35120;撳墠?#27952;褰?#28003;嶇疆<br /> :args : ?#29025;?#28229;褰撳?#23942;?#25779;紑鐨勬墍鏈?#37826;?#28000;?br /> :lcd %:p:h : ?#25980;鍙樿矾寰勫埌褰撳墠缂?#26440;?#37928;勬枃浠?br /> :autocmd BufEnter * lcd %:p:h : 鏀惧叆.vimrc鑷姩瀹?#37812;?#28051;婇潰鐨?#37723;戒护<br /> ----------------------------------------<br /> " 缂?#37712;?#37718;?#23092;?#29785;?涓鐩?#37818;?#37722;?#37715;?0鐨剉im鑴?#37832;?<br /> " 闇瑕?bufexplorer.vim </font><a href="http://www.vim.org/script.php?script_id=42" target="_blank"><font size="4">http://www.vim.org/script.php?script_id=42</font></a><br /> <font size="4">\be : 缂?#37712;?#23092;?#29785;?#37731;?#28051;煡?#28229;缂?#37712;?#37714;?#29723;?br /> \bs : 鍚?#28051;?#38171;?#28003;?#37828;?#37714;嗗壊绐楀彛<br /> ----------------------------------------<br /> " ?#27974;?#23858;澶?#28751;?#37712;?br /> guu : 灏嗘琛?#37928;?#28699;?#23011;嶈浆?#23858;鎴?#28751;?#37712;?br /> gUU : 灏嗘琛?#37928;?#28699;?#23011;嶈浆?#23858;鎴?#28598;?#37712;?br /> Vu : ?#27974;?#23858;閫?#28051;?#37928;勮锛?#28751;?#37712;?#38171;?br /> VU : ?#27974;?#23858;閫?#28051;?#37928;勮锛?#28598;?#37712;?#38171;?br /> g~~ : 鍙?#37722;戣浆?#23858;<br /> vEU : ?#27974;?#23858;璇?#28598;?#37712;?br /> vE~ : 鍙?#37722;戣浆?#23858;璇?br /> ggguG : 灏?#35120;撳墠缂?#26440;戞枃浠?#37712;呭鍏?#38318;浆?#23858;鎴?#28751;?#37712;?br /> " Visually 妯?#23534;?#28051;嬮夋嫨?#22669;鏈?#37928;?#28699;?#23011;?#37721;婃暟瀛?(鏀惧叆 .vimrc鏂?#28000;?#28051;?<br /> vmap ,c :s/\<\(.\)\(\k*\)\>/\u\1\L\2/g<CR><br /> " 澶?#37712;欐墍鏈?#37721;?#28699;?#37928;?#32471;?#28051;?#37340;瀛?#23011;?br /> :%s/[.!?]\_s\+\a/\U&\E/g<br /> ----------------------------------------<br /> gf : 鎵撳紑褰撳墠?#21404;鏍?#28051;?#37812;?#37722;?#37928;勬枃浠?br /> :nnoremap gF :view <cfile><cr> : 鎵撳紑褰撳墠?#21404;鏍?#28051;?#37812;?#37722;?#37928;勬枃浠? 濡?#37835;滀笉瀛樺湪鍒?#37714;涘缓<br /> ga : 鏄?#32448;?#35120;撳墠?#21404;鏍?#28051;?#37719;曚釜瀛?#37928;刟scii,鍗?#26473;?#37714;?#38171;?#37719;?#37711;?#26473;?#37714;?#8230;…<br /> ggVGg? : 灏嗘暣?#37340;鏂?#28000;?#37922;rot13缂?#37934;?#8230;…锛?#29835;佺湅寰楁?#20634;晩~~hoho)<br /> ggg?G : 鍚?#28051;?(閽?#28725;?#28598;?#37826;?#28000;?<br /> :8 | normal VGg? : 灏?#32471;?#37711;?#29723;?#37922;rot13缂?#37934;?br /> :normal 10GVGg? : 鍚?#28051;?br /> <C-A>,<C-X> : 澧?#37716;?#38171;?#37713;?#28751;?#35120;撳墠?#21404;鏍?#28051;?#37928;勬暟瀛?br /> win32 鐢?#37812;?#38343;瑕?#38322;嶅畾涔?CNTRL-A<br /> <C-R>=5*5 : 鎻掑叆25 (灏忓?#23341;绠楀櫒)<br /> ----------------------------------------<br /> " 鍑犱釜褰泲……<br /> :h 42 : also </font><a href="http://www.google.com/search?q=42" target="_blank"><font size="4">http://www.google.com/search?q=42</font></a><br /> <font size="4">:h holy-grail<br /> :h!<br /> ----------------------------------------<br /> " 鏍?#29825;?& 绉诲姩<br /> '. : 璺冲洖鏈鍚庣紪杈?#37928;勮 (瓒?#37832;?#37922;?<br /> `. : 鍚?#28051;?#38171;?#28003;?#37828;畾浣嶇紪杈?#37904;?br /> g; : 璺宠浆?#22476;姣旇緝鏃?#37928;勭紪杈戜?#23943;疆锛?#28641;?#37835;?#37832;?#37928;?#29831;?#38171;?(vim6.3鍚?#37928;勬柊鍔熻兘)<br /> g, : 杩欎釜鏄?#26440;冨績鐨?#28003;嶇疆 (鍚?#28051;?<br /> :changes :鎵?#37713;烘敼鍙樿<br /> :h changelist : ?#29025;?#28229;“?#25980;鍙樿璺宠浆”鐨?#29999;?#37716;?br /> <C-O> : 渚?#23046;?#23052;跨潃浣?#37928;勮?#23456;浆璁?#35120;?#37722;?#37733;?#29882;?(浠?#37832;杩?#37928;?#28051;娆?#23534;濮?<br /> <C-I> : 渚?#23046;?#23052;跨潃浣?#37928;勮?#23456;浆璁?#35120;?#37722;?#37715;嶈烦<br /> :ju(mps) : 鍒楀嚭璺宠浆杞?#26473;?br /> :help jump-motions<br /> :history : 鍒楀?#21700;巻鍙?#29825;?#35120;?br /> :his c : 鍛戒护琛屽巻鍙?br /> :his s : 鎼滅储鍘?#37721;?br /> q/ : 鎼滅储鍛戒护鍘?#37721;?#37928;勭?#26944;彛<br /> q: : 鍛戒护琛?#37723;戒护鍘?#37721;?#37928;勭?#26944;彛<br /> :<C-F> : 鍘?#37721;?#32464;楀彛<br /> ----------------------------------------<br /> " 缂?#37712;?& 鏄犲皠<br /> :map <f7> :'a,'bw! c:/aaa/x<br /> :map <f8> :r c:/aaa/x<br /> :map <f11> :.w! c:/aaa/xr<CR><br /> :map <f12> :r c:/aaa/xr<CR><br /> :ab php : ?#29025;?#28229;浠php寮澶?#37928;勭缉鍐?br /> :map , : 鍒楀嚭?#22669;鏈?#37928;?#37828;犲皠锛?#28000;?#38315;楀彿寮濮?#37928;?#38171;?br /> " 鍏?#29825;?#37828;犲皠 F10 (win32)<br /> set wak=no : :h winaltkeys<br /> " 鏄犲皠涓?#29999;?#28003;?#37922;?#37928;勮绀?br /> <CR> : 鍥?#26462;?br /> <ESC> : Esc<br /> <LEADER> : 鍙?#37826;?#37833;?br /> <BAR> : 绠?#38316;?#32471;?#37721;?br /> <BACKSPACE> : 閫鏍奸敭<br /> <SILENT> : ?#31497;鍥?#37828;?br /> #鏄?#32448;?#38007;畾涔?#37928;?RGB 棰滆壊鏄?#32448;?#35120;撳墠?#21404;鏍?#28051;?#37928;?#28699;?#32471;?#28051;?渚?#28641;?#445588<br /> :nmap <leader>c :hi Normal guibg=#<c-r>=expand("<cword>")<cr><cr><br /> map <f2> /price only\\|versus/ :in a map need to backslash the \<br /> ----------------------------------------<br /> " Simple PHP debugging display all variables yanked into register a<br /> " 绠鍗?#37928;?PHP ?#30367;璇曞?#21976;墍鏈?#37828;?#32448;?#37928;?#37721;?#38322;?#37824;惧叆瀵?#28699;?#37731;a<br /> iab phpdb exit("<hr>Debug <C-R>a ");<br /> ----------------------------------------<br /> " 浣?#37922;?#28725;?#28699;?#37731;?#37833;?#37828;犲皠 (鏀惧叆 .vimrc鏂?#28000;惰嚜?#23017;鍔?#26462;?<br /> :let @m=":'a,'bs/"<br /> :let @s=":%!sort -u"<br /> ----------------------------------------<br /> " 鍒楀嚭瀵?#28699;?#37731;?br /> :reg : 鏄?#32448;?#35120;撳?#23942;墍鏈?#37928;?#28725;?#28699;?#37731;?br /> :reg a : 鏄?#32448;?#28725;?#28699;?#37731;a涓?#37928;?#37712;呭<br /> "1p.... : 寮?#37922;?#28051;?#37340;鍙?鐨?#28725;?#28699;?#37731;?br /> :let @y='yy@"' : pre-loading registers (put in .vimrc)<br /> qqq : 娓呯瀵?#28699;?#37731;?"q"<br /> ----------------------------------------<br /> " 涓浜?#37832;?#37922;?#37928;勫喅绐?br /> "ayy@a : ?#22968;褰撳墠琛?#28003;?#28051;?#37723;戒护鎵?#29723;?br /> yy@" : 涓婇潰鐨勫尶鍚?#28725;?#28699;?#37731;?br /> u@. : 鍙?#37813;?#29723;岄敭?#21446;鐨?#37723;戒护<br /> ----------------------------------------<br /> " 浠庡叾瀹?#37723;戒护澶勮幏寰?#26440;撳叆锛?#38343;瑕?#28598;?#38318;?#37723;戒护锛?br /> :r!ls.exe : 浠巐s 鑾?#23536;?#26440;撳叆鎻掑叆?#22476;褰撳墠浣嶇疆<br /> !!date : 浠巇ate鑾?#23536;?#26440;撳叆锛?#37714;犻櫎褰撳墠琛?#38171;?br /> " 浣?#37922;?#28598;?#38318;sort鎺?#25652;?br /> :%!sort -u : 鐢sort鎺?#25652;忔暣?#37340;鏂?#28000;?#38171;堢粨鏋?#29781;?#37929;?#37825;翠釜鏂?#28000;?#38171;?br /> :'a,'b!sort -u : 浠巑ark a?#22476;mark b涔?#38338;?#37928;?#37712;呭杩?#29723;?#37818;?#25652;?br /> !1} sort -u : 鎺?#25652;?#28051;?#37340;娈佃惤<br /> :g/^$/;,/^$/-1!sort : Sort each block (note the crucial ;)<br /> ----------------------------------------<br /> " 澶?#37826;?#28000;剁鐞?(鍩?#37832;?#37928;?<br /> :bn : 璺宠浆?#22476;涓?#28051;?#37340;buffer<br /> :bp : 璺宠浆?#22476;鍓?#28051;?#37340;buffer<br /> :wn : 淇?#28699;?#35120;撳墠buffer骞惰?#23456;浆?#22476;涓?#28051;?#37340;buffer (瓒?#37832;?#37922;?<br /> :wp : 淇?#28699;?#35120;撳墠buffer骞惰?#23456;浆?#22476;鍓?#28051;?#37340;buffer<br /> :bd : ?#22968;褰撳墠鏂?#28000;?#28000;buffer绉?#37713;?(瓒?#37832;?#37922;?<br /> :bun : 鍗歌浇褰撳墠buffer (鍏?#38338;?#26473;欎釜绐楀彛浣?#37828;笉绉?#37713;?<br /> :badd file.c : 娣诲姞file.c?#22476;buffer鍒?#29723;?br /> :b 3 : 鍓?#23536;绗?#28051;変釜 buffer<br /> :b main : 鍓?#23536;鍚?#37832;main鐨刡uffer涓?姣?#28641;?#29831;?main.c<br /> :sav php.html : ?#22968;褰撳墠鏂?#28000;?#28699;?#28051;簆hp.html骞?#37813;撳紑<br /> :sav! %<.bak : ?#23858;涓?#37340;鍚庣紑鍚?#28103;?#28699;?(鏃?#37826;规硶)<br /> :sav! %:r.cfm : 鍚?#28051;?br /> :sav %:s/fred/joe/ : 鏇挎崲鏂?#28000;?#37722;?br /> :sav %:s/fred/joe/:r.bak2 : 鏇挎崲鏂?#28000;跺拰鍚庣紑<br /> :!mv % %:r.bak : 閲?#37723;?#37722;?#35120;撳墠鏂?#28000;?br /> :e! : 鎵撳紑鏈?#28103;敼涔嬪墠鐨勬枃浠?br /> :w c:/aaa/% : 瀛樺偍鏂?#28000;跺埌鎸囧畾浣嶇疆<br /> :e # : 缂?#26440;戞爣璁?#28051;?鐨勬枃浠跺湪buffer涓?br /> :rew : 杩?#37733;炲埌绗?#28051;?#37340;鍙?#32514;?#26440;?#37928;勬枃浠?br /> :brew : 鍥炲埌绗?#28051;?#37340;buffer<br /> :sp fred.txt : 鍒嗗壊绐楀彛鎵撳紑fred.txt<br /> :sball,:sb : ?#22968;?#22669;鏈?#37928;?buffers鍒嗗壊鏄?#32448;哄湪涓?#37340;绐楀彛涓?(瓒?#37832;?#37922;?<br /> :scrollbind : in each split window<br /> :map <F5> :ls<CR>:e # : 鎸塅5鏄?#32448;烘墍鏈塨uffer, 骞?#37828;?#32448;?#29723;?#37721;?br /> :set hidden : 鍏?#29825;镐笉淇?#28699;?#35120;撳墠buffer鑰?#26473;?#29723;?#37714;囨崲<br /> ----------------------------------------<br /> " ?#28266;鍒嗗壊绐楀彛涓?#36423;?#38315;?#37714;囨崲<br /> map <C-J> <C-W>j<C-W>_<br /> map <C-K> <C-W>k<C-W>_<br /> ----------------------------------------<br /> " 褰?#37714;?#37723;戒护 (鏈濂?#37928;勬妧宸?<br /> qq # 褰?#37714;?#37723;戒护鏀惧叆 q瀵?#28699;?#37731;?br /> 杈撳叆涓浜?#37723;戒护<br /> q # 褰?#37714;剁粨鏉?br /> @q :鎵?#29723;?#37824;惧叆瀵?#28699;?#37731;q涓?#37928;?#37712;呭<br /> @@ 锛?#38322;?#28598;?br /> 5@@ 锛?#38322;?#28598;?娆?br /> " 缂?#26440;戜竴?#37340; 瀵?#28699;?#37731;?褰?#37714;?br /> "qp :鏄?#32448;?#28725;?#28699;?#37731;q涓?#37928;?#37712;呭(鏅?#38315;氭寮?#28051;?<br /> <ctrl-R>q :鏄?#32448;?#28725;?#28699;?#37731;q涓?#37928;?#37712;呭 (鎻掑叆妯?#23534;?#28051;?<br /> " 浣?#37916;板湪鍙?#28000;湅?#22476;璁?#35120;?#37712;呭锛岄渚跨紪杈?br /> "qdd :鍒犻櫎锛岄噸鏂?#28699;樺叆q<br /> @q :鎵?#29723;?褰?#37714;?瀵?#28699;?#37731;?q<br /> " ?#28266;鍙?#29785;嗗潡涓?#26473;?#29723;?#29825;?#35120;?br /> 1) ?#30078;涔?#29825;?#35120;?瀵?#28699;?#37731;?br /> qq:s/ to/ from/g^Mq<br /> 2) ?#30078;涔?#37721;?#29785;嗗潡<br /> V}<br /> 3) ?#25965;?#21446; : 灏?#37828;?#32448;?#28051;嬮潰淇?#37805;?br /> :'<,'><br /> 4)瀹?#37812;?#28641;?#28051;?#37823;?#28003;?br /> :'<,'>norm @q<br /> ----------------------------------------<br /> "combining a recording with a map (to end up in command mode)<br /> nnoremap ] @q:w!<bar>bd<br /> ----------------------------------------<br /> " 鍙?#29785;嗗寲妯?#23534;?#37819;愪緵涓绉嶇伒娲?#37828;?#37922;?#37928;勬?#35268;硶閫夋嫨涓鍧?#37826;?#37832;?#28186;?#37823;?#28003;?#32471;?#28003;?#37922;?br /> " 璁?#37713;?br /> v : 杩涘叆鍙?#29785;嗗寲妯?#23534;?br /> V : 杩涘叆鍙?#29785;嗗寲琛岄夋嫨妯?#23534;?br /> <C-V> : 杩涘叆鍙?#29785;嗗?#26663;潡閫夋嫨妯?#23534;?br /> gv : 閲?#37826;?#38315;夋嫨<br /> o : 閫夋嫨鐨勫?#21700;煙澶?#28751;?#32457;诲姩<br /> "*y : 澶?#37714;?#38315;夋嫨鍖哄?#29111;埌paste buffer<br /> V% : 閫夋嫨涓?#37340;鍖?#38320;嶆<br /> V}J : 鍚?#39582;?#28051;?#37340;娈佃惤<br /> V}gJ : 鍚?#39582;?#28051;?#37340;娈佃惤锛屽苟淇濈暀绌?#37837;?br /> ----------------------------------------<br /> " 鍒犻櫎閫?#28051;?#37928;?0琛?#37928;勫墠涓釜瀛?#32471;?#38171;堜笉杩?#26473;?#38322;屽?#26055;?#20131;璁?#37828;揣鍑?#37928;勬帓鐗?#37837;?#23534;?#38171;屼笉?#20824;鍖呭惈绌?#37837;?#37510;?br /> tab绛?#28699;?#32471;?#37928;?#38171;?#37721;?#37828;?#32513;?#28729;?#26976;屽?#26055;鏄?#38333;??#37340;瀛?#32471;?#37813;?#28725;瑰晩?#32053;?#32053;锛?br /> 0<c-v>10j2ld<br /> ----------------------------------------<br /> " 濡?#28003;?#37922;?#37721;?#29785;嗗?#26945;嫹璐?#37713;?#37714;?br /> " 鍙?#29785;嗗潡(骞?#38344;?#38315;?#29999;?#37928;?v 鍛戒护)<br /> <C-V>锛岀劧鍚?#38315;?#26473;囩?#35826;姩鍛戒护閫夋嫨鍒?(win32 <C-Q>)<br /> ?#21159;鍚庢墽琛?c,d,y,r 绛?#37723;戒护<br /> ----------------------------------------<br /> " how to overwrite a visual-block of text with another such block<br /> Pick the first block: ctrl-v move "ay<br /> Pick the second block: ctrl-v move c ctrl-o "aP <esc><br /> ----------------------------------------<br /> " _vimrc 鍩?#37832;?#29825;?#32515;?br /> :set incsearch : 杈撳叆鎼滅储鍛戒护?#26882;锛?#32468;?#37719;?#37828;?#32448;虹洰鍓?#26440;撳叆鐨勬寮?#28725;?#25652;?#37928;勫尮?#21412;銆?#37718;归厤鐨?#28699;?#32471;?#28051;?br /> 琚珮浜?#37510;?br /> :set wildignore=*.o,*.obj,*.bak,*.exe : tab琛?#37711;椂蹇界暐杩欎?#28056;?#30028;暐杩欎簺<br /> :set shiftwidth=3 : 璁?#32515;?#38007;姩缂?#26473;?#28051;??#37340;瀛?#32471;?br /> :set vb t_vb=". : 瀹?#38344;?#22959;?#23534;?#38171;?#37711;?#38338;?#37725;?#38334;?#29882;?#38338;?#37905;?br /> :set browsedir=buffer : 璁?#32515;?#37826;?#28000;?#23092;?#29785;?#28003;?#37922;?#37928;勭洰褰?br /> “娉?#38171;?br /> ”last 浣?#37922;?#37826;?#28000;?#23092;?#29785;?#37731;?#37832;杩戣闂浉鍚?#37928;勭洰褰?#37510;?br /> “buffer 浣?#37922;浉鍏崇紦鍐?#37718;?#37928;勭洰褰?#37510;?br /> ”current 浣?#37922;?#35120;撳墠?#27952;褰?#37510;?br /> “{path} 浣?#37922;?#37816;囧畾?#27952;褰?#37510;?br /> ----------------------------------------<br /> " 鍚姩windows涓?#37928;IE<br /> :nmap ,f :update<CR>:silent !start c:\progra~1\intern~1\iexplore.exe<br /> file://%:p<CR><br /> :nmap ,i :update<CR>: !start c:\progra~1\intern~1\iexplore.exe <cWORD><CR><br /> ----------------------------------------<br /> " ?#28266;vim閲?#37813;撳紑ftp<br /> cmap ,r :Nread </font><a href="ftp://209.51.134.122/public_html/index.html" target="_blank"><font size="4">ftp://209.51.134.122/public_html/index.html</font></a><br /> <font size="4">cmap ,w :Nwrite </font><a href="ftp://209.51.134.122/public_html/index.html" target="_blank"><font size="4">ftp://209.51.134.122/public_html/index.html</font></a><br /> <font size="4">gvim </font><a href="ftp://www.somedomain.com/index.html" target="_blank"><font size="4">ftp://www.somedomain.com/index.html</font></a><font size="4"> # 浣?#37922;?netrw.vim<br /> ----------------------------------------<br /> " 鍚?#28725;?#28699;?#37731;?#28051;?#23075;诲姞鍐呭 (浣?#37922;浉搴?#28725;?#28699;?#37731;?#37722;嶇鐨?#28598;?#37712;?<br /> " 澶?#37714;?琛?#37824;惧叆a瀵?#28699;?#37731;?#38171;岀劧鍚?#37722;戜?#23341;?#23456;浆10琛?#37712;?#28598;?#37714;?琛?br /> "a5yy<br /> 10j<br /> "A5yy<br /> ----------------------------------------<br /> [I : 鏄?#32448;?#35120;撳墠琛?#28051;?#28699;?#32471;?#37928;勬墍鏈夊尮?#21412;(瓒呯骇鏈?#37922;?<br /> ----------------------------------------<br /> " 甯歌?#21229;缉杩?br /> :'a,'b>> 锛氬皢mark a?#22476;mark b涔?#38338;?#37928;?#37712;呭杩?#29723;?#28051;?#23046;?#32514;?#26473;?br /> " 铏氭?#29112;寮?#28051;嬬缉杩?(鍙?#38322;?#28598;?<br /> :vnoremap < <gv<br /> ”杩?#37828;?#28051;?#37340;铏氭?#29112;寮?#28051;?#37928;勯敭鐩?#37828;犲皠 < 鏄犲皠涓?lt;gv<br /> "< ?#21104;涓?#37722;?#37712;呯缉杩?#38171;実v 涓婇潰宸?#37832;?#29785;噴锛?#28051;?#38322;?#28598;?#28051;婃閫夊尯<br /> “<gv 涔?#28751;?#37828;厛鍚?#37712;呯缉杩涚劧鍚?#37712;?#38315;夋嫨鍒氭墠鐨勯夊尯<br /> “杩?#37837;峰氨鍙?#28000;?#37721;?#37816;?< 瀹?#37916;?#38322;?#28598;嶇缉杩?#27996;?br /> :vnoremap > >gv 锛?#37722;?#37712;呯缉杩?#38171;屽?#29114;悊鍚?#28051;?br /> " 鍧?#32514;?#26473;?br /> >i{<br /> >a{<br /> " also<br /> >% and <%<br /> ”鑷繁璇?#29831;曠湅鍚?#38171;屾秹鍙婂埌鐢?{ 鐨?#29831;?#29815;寰?#37832;?#37922;?#38171;?#23011;?#28641;俢,c++绛?br /> ----------------------------------------<br /> " 閲嶅畾鍚?& 绮樿?#26449;埌瀵?#28699;?#37731;?* 锛?涓?#28725;?#28699;?#37731;?#37722;嶇锛?br /> :redir @* : 閲嶅畾鍚?#37723;戒护?#22476;paste缂?#37712;?#37718;?br /> :redir END : ?#31912;鏉?br /> :redir >> out.txt : 閲嶅畾鍚戝埌鏂?#28000;?br /> " 鎿?#28003;滅?#27199;?#23544;紦鍐?#37718;?br /> "*yy : 澶?#37714;跺埌瀵?#28699;?#37731;?br /> "*p : 浠庡瘎瀛?#37731;?#28051;?#32494;樿创涓琛?br /> " 澶?#37714;跺埌绮樿?#23544;紦鍐?#37718;?(鎵?#28766;曟寮?<br /> :'a,'by* : 澶?#37714;?#28051;?#37340;鑼冨洿?#22476;绮樿创瀵?#28699;?#37731;?br /> :%y* : 澶?#37714;?#28051;?#37340;?#23277;鍙峰尮?#21412;?#22476;绮樿?#23544;紦鍐?#37718;?br /> :.y* : 澶?#37714;?#35120;撳墠琛屽埌绮樿?#23544;紦鍐?#37718;?br /> " 浠庡壀璐?#37833;?#28051;?#26473;囨护闈?#37721;?#37813;撳瀛?#32471;?br /> " 褰?#28000;?#28051;浜?GUI 绋?#25652;忕?#27199;?#23384;椂?#32048;鏈?#37922;?#28598;?br /> :nmap <leader>p :let @* = substitute(@*,'[^[:print:]]','','g')<cr>"*p<br /> ----------------------------------------<br /> " 閲?#37826;?#37837;?#23534;?#37718;?#37826;?#37832;?br /> gq} : 鍚?#39582;?#28051;?#37340;娈佃惤<br /> gqap : 褰撳?#23942;?#20291;惤<br /> ggVGgq : 鍏?#38318;?#23048;佃惤<br /> Vgq : 褰撳墠琛?br /> " ?#28266;70鍒?#37928;勬椂鍊欐崲琛?br /> :s/.\{,69\};\s*\|.\{,69\}\s\+/&\r/g<br /> ----------------------------------------<br /> " 鍛戒护浣?#37922;?#27996;?#28598;氫釜鏂?#28000;?br /> :argdo %s/foo/bar/e : ?#28266;?#22669;鏈?#37826;?#28000;?#28051;婃?#23941;仛 :args<br /> :bufdo %s/foo/bar/e<br /> :windo %s/foo/bar/e<br /> :argdo exe '%!sort'|w! : 鍖呭惈澶?#38318;?#37723;戒护<br /> ----------------------------------------<br /> " 鍛戒护琛屾妧宸?br /> gvim -h : 鏄?#32448;?#29999;?#37716;?br /> ls | gvim - : 绠?#38316;撴搷浣?br /> cat xx | gvim - -c "v/^\d\d\|^[3-9]/d " : 浠庣閬?#37713;?#26473;囨护鍐呭<br /> gvim -o file1 file2 : 鍒嗗壊绐楀彛鏄?#32448;?#28051;釜鏂?#28000;?br /> " 鎵撳紑鏂?#28000;?#37722;庢墽琛?#28051;鏉?#37723;戒护<br /> gvim.exe -c "/main" joe.c : 鎵撳紑 joe.c & 璺宠浆?#22476; "main"<br /> " ?#28266;鎵撳紑涓?#37340;鏂?#28000;舵椂鎵?#29723;?#28598;?#37833;?#37723;戒护<br /> vim -c "%s/ABC/DEF/ge | update" file1.c<br /> " ?#28266;涓缁勬枃浠?#28051;?#37813;?#29723;?#28598;?#37833;?#37723;戒护<br /> vim -c "argdo %s/ABC/DEF/ge | update" *.c<br /> " 浠?#28051;绯?#37714;?#37826;?#28000;?#28051;?#37714;犻櫎涓鍧楀?#21700;煙<br /> vim -c "argdo /begin/+1,/end/-1g/^/d | update" *.c<br /> " 鑷姩缂?#26440;戞枃浠?(缂?#26440;?#37723;戒护搴?#37714;Ex commands宸?#32513;?#37718;呭惈?#28266;convert.vim涓?#27996;?<br /> vim -s "convert.vim" file.c<br /> #?#31497;鍔?#26462;?vimrc璺?#28000;?#28003;昿lugin(骞?#37713;娓?#37826;?#37928;?VIM^_^)<br /> gvim -u NONE -U NONE -N<br /> " Access paste buffer contents (put in a script/batch file)<br /> gvim -c 'normal ggdG"*p' c:/aaa/xp<br /> " 灏唒aste涓?#37928;?#37712;呭閫?#23536;榛樿鐨勬?#25779;鏈?br /> gvim -c 's/^/\=@*/|hardcopy!|q!'<br /> " gvim 閲?#37928;?grep (win32 or *nix)<br /> :grep somestring *.php : 鍒涘缓鍖归厤鐨勬枃浠?#37714;?#29723;?br /> " 浣?#37922;?:cn(鍚?#37722;?#37722;? :cp(鍚?#37715;? 鎿嶇旱鍒?#29723;?br /> :h grep 锛氭煡?#28229;甯?#37716;?br /> ----------------------------------------<br /> " GVIM 鐨勫樊寮?#23011;旇緝<br /> gvim -d file1 file2 : vimdiff (姣旇?#20903;笉宸?#23534;?<br /> dp : ?#22968;?#21404;鏍?#28598;?#37928;勪笉鍚?#37824;惧埌鍙?#28051;?#37340;鏂?#28000;?br /> do : ?#28266;?#21404;鏍?#28598;?#28000;?#37721;?#28051;?#37340;鏂?#28000;?#37721;栧緱?#31497;鍚?br /> ----------------------------------------<br /> " Vim traps<br /> ?#28266;姝?#37714;?#29723;?#26440;?#23534;?#28051;?+ | ( { 閮?#29781;?#37716;?#28051;婅浆涔?#32471;?鍙?#37826;?#37833;?<br /> /fred\+/ : 鍖归厤 fred/freddy 浣嗕笉鍖归厤 free<br /> /\(fred\)\{2,3}/ : note what you have to break<br /> ----------------------------------------<br /> " \v 锛?#37812;?#37721;?#37707;very magic (閫?#29999;?#38318;?#37828;?#26473;欎箞鍙?鍙?#28000;?#37721;?#23057;堣浆涔?#32471;?br /> /codes\(\n\|\s\)*where : 鏅?#38315;?#37928;勬鍒?#29723;?#26440;?#23534;?br /> /\vcodes(\n|\s)*where : very magic<br /> ----------------------------------------<br /> " ?#22968;瀵硅薄閫佸埌鍛戒护琛?#37812;?#38000;呮?#28357;储琛?br /> <C-R><C-W> : 鎵?#29723;屽?#25779;墠?#21404;鏍?#28051;?#37928;?#37719;曚釜鍗?#29831;?br /> <C-R><C-A> : 鎵?#29723;屽?#25779;墠?#21404;鏍?#28051;嬪敖鍙兘澶?#37928;?#37719;?#29831;?br /> <C-R>- : 閫?#38007;?#28051;?#37340;灏忓瀷瀵?#28699;?#37731;?#38171;?#37722;?#37837;蜂娇鐢?#27996;?#37819;掑叆妯?#23534;?#38171;?br /> <C-R>[0-9a-z] : 閫?#38007;?#28051;?#37340;鍛?#37722;?#28725;?#28699;?#37731;?(?#23277;寮?#37722;?#28051;?<br /> <C-R>% : 閫?#38007;?#37826;?#28000;?#37722;?#涔?#29723;? (鍚?#28051;?<br /> <C-R>=somevar : 閫?#38007;?#28051;?#37340;鍙?#38322;?(渚?#28641;?:let sray="ray[0-9]")<br /> ----------------------------------------<br /> " 鎺?#37714;?#28725;?#28699;?#37731;?br /> :let @a=@_ : 娓呴櫎瀵?#28699;?#37731;?a<br /> :let @a="" : 鍚?#28051;?a<br /> :let @*=@a : 鎷?#29840;?#28725;?#28699;?#37731;?a ?#22476; paste buffer<br /> :let @*=@: : 鎷?#29840;?#37832;鍚庢墽琛?#37928;?#37723;戒护?#22476; paste buffer<br /> :let @*=@/ : 鎷?#29840;?#37832;鍚庢墽琛?#37928;勬煡鎵?#37723;戒护?#22476;paste buffer<br /> :let @*=@% : 鎷?#29840;?#35120;撳墠鏂?#28000;跺埌 paste buffer<br /> <br /> map <f11> "qyy:let @q=@q."zzz"<br /> ----------------------------------------<br /> " 甯?#37716;?#37928;?#29999;?#37716;紵 (浣?#37922;?TAB)<br /> :h quickref : VIM 蹇?#38315;?#37721;?#38000;?#26916;?br /> :h tips : Vim'鑷繁鐨勬妧宸?#29999;?#37716;?br /> :h visual<C-D><tab> : 铏氭?#29112;寮?#37928;?#29999;?#37716;?#37714;?#29723;?br /> : ?#21159;鍚?#28003;?#37922;tab閫夋嫨瀹冧滑<br /> :h ctrl<C-D> : ?#22669;鏈夊叧浜巆trl?#25965;鐨?#29999;?#37716;?#37714;?#29723;?br /> :helpg uganda : 杩囨护甯?#37716;?#37826;?#28000;?浣?#37922;?:cn, :cp ?#29025;鎵?#28051;?#28051;?#37340;鍙?#37722;?#28051;?#37340;<br /> :h :r : 鍏?#27996;?:ex 鐨?#37723;戒护甯?#37716;?br /> :h CTRL-R : 鏅?#38315;氭寮忕浉鍏?br /> :h /\r : \r鏄?#28000;涔?#37928;勬剰鎬?br /> :h \\zs : 浣?#37922;?#37721;?#37721;?#37826;滅?#25358;煡鎵?#37711;?#27996;?\zs 鐨?#29999;?#37716;?br /> :h i_CTRL-R : ?#28266;鎻掑叆妯?#23534;?#28051;?<C-R>鐨勮?#22132;<br /> :h c_CTRL-R : ?#28266;鍛戒护妯?#23534;?#28051;?<C-R> 鐨勮?#22132;<br /> :h v_CTRL-V : 铏氭?#29112;寮?br /> :h tutor : VIM 蹇?#38315;?#37816;囧<br /> <C-[>, <C-T> : Move back & Forth in HELP History<br /> gvim -h : VIM 鍛戒护琛?#29999;?#37716;?br /> ----------------------------------------<br /> " 閫?#26916;?#29825;?#32515;湪閭?#38322;?br /> :scriptnames : 鍒楀嚭?#22669;鏈夊凡缁?#37716;?#26462;?#37928;?plugins, _vimrcs鏂?#28000;?br /> :verbose set history? :鏄?#32448;?history鐨?#37706;?#39582;?#37828;?#32448;哄湪閭?#38322;屽畾涔?#37928;?br /> :function : 鍒楀嚭?#22669;鏈?#37713;芥暟<br /> :func SearchCompl : 鏄?#32448;?#37816;囧畾鍑芥暟鐨?#32513;嗚妭<br /> ----------------------------------------<br /> " 鍒?#28003;?#28003;?#38007;繁鐨刅IM 甯?#37716;?br /> :helptags /vim/vim64/doc : 閲?#37826;扮紪璇戞墍鏈?*.txt 鐨?#29999;?#37716;?#37826;?#28000;跺湪杩欎釜?#27952;褰?#38322;?br /> :help add-local-help 锛?#28641;?#28003;曟?#35826;姞鏈?#37734;?#29999;?#37716;?br /> ----------------------------------------<br /> " 鐢?#28598;?#38318;?#32459;?#25652;?#26473;?#29723;?#37826;?#28000;?(渚?#28641;?php)<br /> map <f9> :w<CR>:!c:/php/php.exe %<CR><br /> map <f2> :w<CR>:!perl -c %<CR><br /> ----------------------------------------<br /> " ?#28266;鍙?#28051;?#37340;buffer涓?#38171;屾崟鎹夊?#25779;?#23944;剼鏈?#37928;勮緭鍑?br /> :new | r!perl # : 鏂板缓涓?#37340;buffer锛?#28000;?#37721;?#28051;?#37340;buffer涓?#29831;诲叆?#31912;鏋?br /> :new! x.out | r!perl # : 鍚?#28051;?#38171;屽苟鎸囧畾涓?#37340;鏂?#37826;?#28000;?#37722;?br /> :new+read!ls<br /> ----------------------------------------<br /> " create a new buffer, paste a register "q" into it, then sort new buffer<br /> :new +put q|%!sort<br /> ----------------------------------------<br /> " 鎻掑叆DOS?#23858;琛?#32471;?br /> :%s/$/\<C-V><C-M>&/g : (that's what you type<br /> :%s/$/\<C-Q><C-M>&/g : for Win32) 瀵?#27996;Win32搴旇杩?#37837;?br /> :%s/$/\^M&/g : 浣犵湅?#22476;鐨^M鏄?#28051;?#37340;瀛?#32471;?br /> ----------------------------------------<br /> " 鑷姩鍒犻櫎琛屽熬 Dos鍥?#26462;?#32471;?#37724;岀鏍?br /> autocmd BufRead * silent! %s/[\r \t]\+$//<br /> autocmd BufEnter *.php :%s/[ \t\r]\+$//e<br /> ----------------------------------------<br /> " 瀵规?#22247;畾鏂?#28000;?#37812;?#37826;?#28000;?#32491;诲瀷鎵?#29723;?#37836;愪釜?#23017;浣?br /> autocmd VimEnter c:/intranet/note011.txt normal! ggVGg?<br /> autocmd FileType *.pl exec('set fileformats=unix')<br /> ----------------------------------------<br /> " ?#22968;鏈鍚?#28051;?#37340;鍛戒护璐村埌褰撳墠浣嶇疆<br /> i<c-r>:<br /> " ?#22968;鏈鍚?#28051;?#37340;鎼滅储鎸囦护璐村埌褰撳墠浣嶇疆<br /> i<c-r>/<br /> ----------------------------------------<br /> " 鏇?#28598;?#37928;?#28729;?#37812;?#37716;熻兘<br /> <C-X><C-F> :鎻掑叆褰撳墠?#27952;褰?#28051;?#37928;?#28051;?#37340;鏂?#28000;?#37722;嶅埌褰撳墠浣嶇疆<br /> # ?#28266;insert妯?#23534;?#28051;?#28003;?#37922;?br /> # ?#21159;鍚?#37922;?Ctrl-P/Ctrl-N 缈?#26916;?br /> ----------------------------------------<br /> " 鏇挎崲涓?#37340;visual鍖哄煙<br /> " 閫夋嫨涓?#37340;鍖哄煙锛岀劧鍚?#26440;撳叆 :s/Emacs/Vim/ 绛?#32475;?#38171;寁im?#32048;鑷姩杩涘叆:妯?#23534;?br /> :'<,'>s/Emacs/Vim/g : 鍓嶉潰鐨? '<.'> 鏄痸im鑷姩娣诲姞鐨?br /> gv : 閲?#37826;?#38315;夋嫨鍓?#28051;?#37340;鍙?#29785;嗗?#21700;煙 (ULTRA)<br /> ----------------------------------------<br /> " ?#28266;鏂?#28000;?#28051;?#37819;掑叆琛?#37721;?br /> :g/^/exec "s/^/".strpart(line(".")." ", 0, 4)<br /> :%s/^/\=strpart(line(".")." ", 0, 5)<br /> :%s/^/\=line('.'). ' '<br /> ----------------------------------------<br /> #鐢VIM鐨勬柟寮?#37833;?#32514;?#37721;?#29723;?br /> :set number : 鏄?#32448;?#29723;?#37721;?br /> :map <F12> :set number!<CR> : Show linenumbers flip-flop<br /> :%s/^/\=strpart(line('.')." ",0,&ts)<br /> #浠?#28000;绘剰琛屽紑濮嬬紪鍙?闇瑕乸erl)<br /> :'a,'b!perl -pne 'BEGIN{$a=223} substr($_,2,0)=$a++'<br /> #?#39559;鐢熸暟瀛楀垪琛?br /> #Type in number on line say 223 in an empty file<br /> qqmnYP`n^Aq : in recording q repeat with @q<br /> " 閫?#28583;?#23480;?#28699;樺湪?#26271;瀛楀埌鏂?#28000;?#37832;?br /> :.,$g/^\d/exe "normal! \<c-a>"<br /> " ?#29678;?#39559;閫?#28583;?#38171;?#37721;?#29785;?#38171;?br /> </font><a href="http://vim.sourceforge.net/tip_view.php?tip_id=150" target="_blank"><font size="4">http://vim.sourceforge.net/tip_view.php?tip_id=150</font></a><br /> <font size="4">----------------------------------------<br /> " ?#29678;?#39559;閫?#28583;?(鐪?#37928;?#23536;?#37832;?#37922;?<br /> " ?#22968;涓嬮潰鍑?#37721;?#37824;惧埌 _vimrc<br /> let g:I=0<br /> function! INC(increment)<br /> let g:I =g:I + a:increment<br /> return g:I<br /> endfunction<br /> " 渚?#28641;備粠mark a ?#22476;mark b 閫?#28583;?#38171;?#28000;?23寮濮?#38171;屾闀?#28051;?<br /> :let I=223<br /> :'a,'bs/^/\=INC(5)/<br /> " create a map for INC<br /> cab viminc :let I=223 \| 'a,'bs/$/\=INC(5)/<br /> ----------------------------------------<br /> " 鐢?#37812;?#28000;?23-64 鐨勬暟瀛楀垪琛?br /> o23<ESC>qqYp<C-A>q40@q<br /> ----------------------------------------<br /> " ?#28266;褰撳墠鎻掑叆妯?#23534;?#28051;嬬紪杈?绉诲姩 (鐪?#23536;楀緢鏈?#37922;?<br /> <C-U> : 鍒犻櫎鍏?#38318;?br /> <C-W> : 鍒犻櫎鏈鍚?#28051;?#37340;鍗?#29831;?br /> <HOME><END> : 绉诲姩?#22476;琛?#26851;?琛屽熬<br /> <C-LEFTARROW><C-RIGHTARROW> : 鍚?#37715;?鍚庣?#35826;姩涓?#37340;鍗?#29831;?br /> <C-X><C-E>,<C-X><C-Y> : scroll while staying put in insert<br /> ----------------------------------------<br /> #鍔犲瘑(灏忓績浣?#37922;?#38171;屼笉瑕佸繕浜嗗瘑鐮?<br /> :X : vim?#32048;鎻愮浣?#26440;撳叆?#30225;鐮?br /> :h :X<br /> ----------------------------------------<br /> " 妯?#23534;?#29723;?(浣挎枃浠?#37721;?#29831;荤瓑)锛屽繀椤诲湪鍓?鍚?5琛?#37712;?br /> // vim:noai:ts=2:sw=4:readonly:<br /> " vim:ft=html: : 浣?#37922;?HTML 璇硶?#29678;浜?br /> :h modeline<br /> ----------------------------------------<br /> " 寤?#32468;?#28003;?#38007;繁鐨勮鍗?#26916;?br /> amenu Modeline.Insert\ a\ VIM\ modeline <Esc><Esc>ggOvim:ff=unix ts=4 ss=4<CR><br /> vim60:fdm=marker<esc>gg<br /> ----------------------------------------<br /> " 涓?#37340;淇?#28699;?#35120;撳墠?#21404;鏍?#28051;?#37928;勭嫮涔?#28699;楀埌涓?#37340;鏂?#28000;?#37928;?#37713;芥暟<br /> function! SaveWord()<br /> normal yiw<br /> exe ':!echo '.@0.' >> word.txt'<br /> endfunction<br /> map ,p :call SaveWord()<br /> ----------------------------------------<br /> " 鍒犻櫎閲?#28598;?#29723;?#37928;?#37713;芥暟<br /> function! Del()<br /> if getline(".") == getline(line(".") - 1)<br /> norm dd<br /> endif<br /> endfunction<br /> <br /> :g/^/ call Del() #浣?#37922;?#29831;?#37713;芥暟鐨?#28051;?#37340;渚?#28699;?br /> ----------------------------------------<br /> " 鍙?#28699;楄?#20636;紪鐮?(non alpha-numerics)<br /> :digraphs : 鏄?#32448;虹紪鐮?#29723;?br /> :h dig : 甯?#37716;?br /> i<C-K>e' : 杈撳叆 é<br /> i<C-V>233 : 杈撳叆 é (Unix)<br /> i<C-Q>233 : 杈撳叆 é (Win32)<br /> ga : ?#29025;?#28229;瀛?#32471;?#37928;刪ex鍊?br /> #鍒犻櫎闈?ascii 瀛?#32471;?br /> :%s/[<C-V>128-<C-V>255]//gi : where you have to type the Control-V<br /> :%s/[?-?]//gi : Should see a black square & a dotted y<br /> :%s/[<C-V>128-<C-V>255<C-V>01-<C-V>31]//gi : All pesky non-asciis<br /> :exec "norm /[\x00-\x1f\x80-\xff]/" : same thing<br /> #Pull a non-ascii character onto search bar<br /> yl/<C-R>" :<br /> /[^a-zA-Z0-9_[:space:][:punct:]] : search for all non-ascii<br /> ----------------------------------------<br /> " 鏂?#28000;?#37722;嶈嚜?#23017;瀹?#37812;?(渚?#28641;?main_c.c)<br /> :e main_<tab> : tab ?#25965;瀹?#37812;?br /> gf : 鎵撳紑?#21404;鏍?#28598;勫箍涔?#28699;楀懡鍚?#37928;勬枃浠?(normal妯?#23534;?<br /> main_<C-X><C-F> : 鏂?#28000;?#37722;嶈嚜?#23017;瀹?#37812;?insert妯?#23534;?<br /> ----------------------------------------<br /> " Vim澶?#37833;?#28003;?#37922;?br /> " 浜崲涓釜鍗?#29831;?br /> :%s/\<\(on\|off\)\>/\=strpart("offon", 3 * ("off" == submatch(0)), 3)/g<br /> " 浜崲涓釜鍗?#29831;?br /> :vnoremap <C-X> <Esc>`.``gvP``P<br /> ----------------------------------------<br /> " ?#22968;text鏂?#28000;惰浆?#23858;鎴恏tml鏂?#28000;?oh,ft)<br /> :runtime! syntax/2html.vim : ?#27974;?#23858; txt 鎴?html<br /> :h 2html<br /> ----------------------------------------<br /> " VIM 鏈?#28051;?#37340;鍐?#38318;?#38007;?#29999;?#37928;?grep 鍛戒护<br /> :grep some_keyword *.c : 寰楀埌涓?#37340;鍖呭惈some_keyword鐨刢鏂?#28000;?#37722;?#37714;?#29723;?br /> :cn : 鍘?#28051;?#28051;?#37340;鍑?#37916;?#37928;?#28003;嶇疆<br /> ----------------------------------------<br /> " 寮?#37714;?#37827;?#37813;?#28766;?#37722;?#37928;勬枃浠?#37928;?#29831;硶?#28483;鑹?#37826;?#23534;?br /> :set syntax=perl<br /> " 鍙?#23057;?#29831;硶?#28483;鑹?(寰?#37832;?#37922;?<br /> :set syntax off<br /> " ?#25980;鍙樿壊褰?#28051;?#26864;?(?#28266;~vim/vim??/colors涓?#37928;?#28000;?#28003;?#37826;?#28000;?<br /> :colorscheme blue<br /> " 閫?#26473;?#28003;?#37922;?#22959;?#23534;?#29723;屽己杩?#28003;?#37922;?HTML 璇硶?#29678;浜?br /> # vim:ft=html:<br /> " 寮?#37714;惰嚜?#23017;璇硶鍔?#27996;?闈?#37837;囧噯鐨勬枃浠?#37813;?#28766;?<br /> au BufRead,BufNewFile */Content.IE?/* setfiletype html<br /> ----------------------------------------<br /> :set noma (non modifiable) : 闃?#23005;?#28103;敼<br /> :set ro (Read Only) : 鍙?#29831;?#28103;?#37814;?br /> ----------------------------------------<br /> " 瀵?#29831;?(鎵撳紑涓?#29218;鏂?#28000;?<br /> gvim file1.c file2.c lib/lib.h lib/lib2.h : ?#28266;"瀵?#29831;?涓?#37716;?#26462;?#26473;欎簺鏂?#28000;?br /> :mksession : 鐢?#37812;?#28051;?#37340;Session鏂?#28000;?(榛樿鏄疭ession.vim)<br /> :q<br /> gvim -S Session.vim : 閲?#37826;?#37716;?#26462;芥墍鏈?#37826;?#28000;?br /> ----------------------------------------<br /> #鏍?#29825;?tags) (璺宠浆?#22476;瀛愮搴?鍑芥暟)<br /> taglist.vim : 寰?#23092;?#29723;?#37928;勬彃浠?br /> :Tlist : 鏄?#32448;?#37837;?#29825;?(鍑芥暟鍒?#29723;?<br /> <C-]> : 璺宠浆?#22476;?#21404;鏍?#28598;?#37928;?#37713;芥暟<br /> ----------------------------------------<br /> " columnise a csv file for display only as may crop wide columns<br /> :let width = 20<br /> :let fill=' ' | while strlen(fill) < width | let fill=fill.fill | endwhile<br /> :%s/\([^;]*\);\=/\=strpart(submatch(1).fill, 0, width)/ge<br /> :%s/\s\+$//ge<br /> " Highlight a particular csv column (put in .vimrc)<br /> function! CSVH(x)<br /> execute 'match Keyword /^\([^,]*,\)\{'.a:x.'}\zs[^,]*/'<br /> execute 'normal ^'.a:x.'f,'<br /> endfunction<br /> command! -nargs=1 Csv :call CSVH(<args>)<br /> " call with<br /> :Csv 5 : highlight fifth column<br /> ----------------------------------------<br /> " 鎶?#37721;?#38171;?#38341;愯棌鏌愪?#28058;墖鏂?#38171;?#28003;挎煡?#28229;鏇?#28729;?#37828;?br /> zf} : 浣?#37922;姩浣?#37723;戒护鎶?#37721;?#28051;?#37340;娈佃惤<br /> v}zf : 浣?#37922;?#37721;?#29785;嗘寮忔鍙?#28051;?#37340;娈佃惤<br /> zf'a : 鎶?#37721;犲埌涓?#37340;鏍?#29825;?#28051;?br /> zo : 鎵撳紑鎶?#37721;?br /> zc : 閲?#37826;?#37711;?#38338;?#37814;?#37721;?br /> ----------------------------------------<br /> " 鏄?#32448;??#31497;鍙?#29785;?#28699;?#32471;?<br /> :set list<br /> :h listchars<br /> ----------------------------------------<br /> " 濡?#28003;曞湪?#31497;杩涘叆鎻掑叆妯?#23534;?#37928;勬?#21613;喌涓嬬?#27199;创"鏅?#38315;氭寮?#37928;?#37723;戒护"<br /> :norm qqy$jq<br /> ----------------------------------------<br /> " 澶勭悊鏂?#28000;?#37722;?br /> :h filename-modifiers : 甯?#37716;?br /> :w % : 鍐欏叆褰撳墠鏂?#28000;?br /> :w %:r.cfm : ?#25980;鍙?#37826;?#28000;?#37813;?#28766;?#37722;?#28051;?.cfm<br /> :!echo %:p : 鏄?#32448;?#28729;屾暣?#30718;寰勫拰鏂?#28000;?#37722;?br /> :!echo %:p:h : 鍙?#37828;?#32448;?#28729;屾暣?#30718;寰?br /> :!echo %:t : 鍙?#37828;?#32448;?#37826;?#28000;?#37722;?br /> :reg % : 鏄?#32448;?#37826;?#28000;?#37722;?br /> <C-R>% : 鎻掑叆鏂?#28000;?#37722;?(鎻掑叆妯?#23534;?<br /> "%p : 鎻掑叆鏂?#28000;?#37722;?(鏅?#38315;氭寮?<br /> /<C-R>% : ?#28266;鏂?#37832;?#28051;煡鎵?#37826;?#28000;?#37722;?br /> ----------------------------------------<br /> " 鍒犻櫎锛?#28003;嗕笉鐮村 buffer 鍐呭<br /> "_d : 浣?#28051;鐩?#37807;?#29781;?#37928;?#28051;滆<br /> "_dw : 渚?#28641;?#38171;?#37714;犻櫎涓?#37340;鍗?#29831;?(浣?#37922;?#27035;戞礊???)<br /> ----------------------------------------<br /> " 閫?#28729;屾暣鐨勮矾寰?#37722;嶅埌鍓?#29840;?#37833;?#38171;?#37922;?#27996;庨偖浠堕浠剁瓑<br /> nnoremap <F2> :let @*=expand("%:p")<cr> :unix<br /> nnoremap <F2> :let @*=substitute(expand("%:p"), "/", "\\", "g")<cr> :win32<br /> ----------------------------------------<br /> " ?#31497;鐢?#32450;?#23534; Vim 灏?#38003;戒慨?#25980;鏂?#28000;?#37722;?#37928;勭畝鍗?shell 鑴?#37832;?br /> $ vim<br /> :r! ls *.c<br /> :%s/\(.*\).c/mv & \1.bla<br /> :w !sh<br /> :q!<br /> ----------------------------------------<br /> " ?#28266;涓?#37340;鏂?#37832;?#38322;?#29825;?#32480;楀崟璇嶆暟<br /> g<C-G><br /> ----------------------------------------<br /> " 浣?#38007;繁璁?#32515;珮浜?#37828;?#32448;?#37928;勪緥瀛?br /> :syn match DoubleSpace " "<br /> :hi def DoubleSpace guibg=#e0e0e0<br /> ----------------------------------------<br /> " reproduce previous line word by word<br /> imap ] @@@<ESC>hhkyWjl?@@@<CR>P/@@@<CR>3s<br /> nmap ] i@@@<ESC>hhkyWjl?@@@<CR>P/@@@<CR>3s<br /> " 鏍规嵁鏂?#28000;?#32491;诲瀷鏄犲?#21227;揩鎹烽敭<br /> :autocmd bufenter *.tex map <F1> :!latex %<CR><br /> :autocmd bufenter *.tex map <F2> :!xdvi -hush %<.dvi&<CR><br /> ----------------------------------------<br /> " 璇?#37721;?MS-Word 鏂囨锛?#38343;瑕?antiword<br /> :autocmd BufReadPre *.doc set ro<br /> :autocmd BufReadPre *.doc set hlsearch!<br /> :autocmd BufReadPost *.doc %!antiword "%"<br /> ----------------------------------------<br /> " a folding method<br /> vim: filetype=help foldmethod=marker foldmarker=<<<,>>><br /> A really big section closed with a tag <<<<br /> --- remember folds can be nested ---<br /> Closing tag >>><br /> ----------------------------------------<br /> " Just Another Vim Hacker JAVH<br /> vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"<br /> # 璇戦噴锛?#37723;?#37723;?#38171;岃皝鏉?#29785;噴涓涓?#37722;?#38171;?br /> # 鍏?#28729;炰笉杩?#37828;湪鍚姩vim鐨勬椂鍊?#37813;?#29723;屼簡涓?#37340;鍛戒护<br /> # ?#21403;鍐欏叆浜?Just Another Vim Hacker 鐨剅ot13缂?#37934;?br /> # ?#21159;鍚?#37712;?#29785;?#37934;?/font></div> <br /> <img src ="http://www.67529968.com/lingy/aggbug/293576.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2009-09-02 12:25 <a href="http://www.67529968.com/lingy/archive/2009/09/02/293576.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>vim 鏄?#32448;?#29723;?#37721;?#37510;?#29831;硶?#29678;浜?#37510;?#38007;姩缂?#26473;?#37928;勮缃?/title><link>http://www.67529968.com/lingy/archive/2009/09/02/293574.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Wed, 02 Sep 2009 04:24:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2009/09/02/293574.html</guid><description><![CDATA[<p>?#28266;Ubuntu涓璿im鐨勯?#23943;疆鏂?#28000;?#28699;?#37824;惧湪/etc/vim?#27952;褰?#28051;?#38171;岄?#23943;疆鏂?#28000;?#37722;?#28051;vimrc</p> <p>?#28266;Fedora涓璿im鐨勯?#23943;疆鏂?#28000;?#28699;?#37824;惧湪/etc?#27952;褰?#28051;?#38171;岄?#23943;疆鏂?#28000;?#37722;?#28051;vimrc</p> <p>?#28266;缁?#32468;?杈撳叆浠?#28051;?#37723;戒护鏉?#32514;?#26440;憊imrc閰嶇疆鏂?#28000;?#38171;?br /> sudo vim /etc/vim/vimrc<br /> 鎴?#38000;?sudo gedit /etc/vim/vimrc</p> <p>1銆?#37828;?#32448;?#29723;?#37721;?br />    <br /> ?#28266;鏂?#28000;?#37832;?#32468;?#23075;诲姞涓鏂拌锛?#26440;撳叆 set nu</p> <p>2銆?#29831;硶?#29678;浜?br /> ?#28266;鏂?#28000;?#28051;?#37813;惧埌 "syntax on   杩欎竴琛?#38171;屽幓鎺夊墠?#28528;鐨?#37721;屽紩鍙?锛?#37721;屽紩鍙?#37828;?#23049;噴鐨勬剰鎬?/p> <p>3銆?#38007;姩缂?#26473;?/p> <p>?#28266;鏂?#28000;?#37832;?#28751;炬?#35826;姞涓琛?#38171;?#26440;撳叆  set autoindent<br /> ?#28266;娣诲姞涓琛?#38171;?#26440;撳叆         set cindent<br /> 鍏?#28051;?autoindent 鏄?#38007;姩缂?#26473;?#38171;?cindent鏄?#37911;?#37714;?#38333;?#28725;?C璇?#29815;璇?#23049;曡嚜?#23017;缂?#26473;?/p> <p>娉剰锛?#28641;?#37835;?#29825;?#32515;?#28610;戒互涓?#29825;?#32515;?#37722;?#38171;VIM?#30149;鏈?#28003;?#37713;虹浉搴?#37928;勫姩浣?#38171;岄偅涔?#29831;蜂?#29363;妸浣?#37928;刅IM鍗囩骇?#22476;鏈鏂?#37911;?#38171;?#28051;鑸?#37721;?#29781;佸湪缁?#32468;?#26440;撳叆浠?#28051;?#37723;戒护鍗?#37721;?#38171;歴udo apt-get install vim</p> <p>绁?#28598;?#28729;?#28003;?#37922;VIM鎰夊揩锛?/p> <p> </p> <p><br /> 涓嬮潰鍛?#29831;?#28598;?#28729;?#37804;?#28052;堝湪linux涓?#28699;範C锛孋?#28266;linux涓?#37928;勭紪璇?#37731;?#37828;gcc锛?#28003;犲湪缁?#32468;?#37922;vim杈撳叆C鐨勬?#24878;爜</p> <p>          濡?#28051;?#28103;?#28699;樺埌hello.c?#21159;鍚庡湪鍛戒护琛?#26473;?#29723;?#38171;?/p> <p> </p> <p>          锛?gcc hello.c -o hello</p> <p> </p> <p>          杩?#37837;蜂細鐢?#37812;?#28051;?#37340;hello鐨?#37721;?#37813;?#29723;?#37826;?#28000;?#38171;屽湪鍛戒护琛岄噷杈撳叆锛?/p> <p> </p> <p>          锛?./hello</p> <p> </p> <p>          灏辫兘杩?#29723;?#37714;?#37714;?#28003;犵紪璇?#37928;凜婧愮爜浜?/p> <p> </p> <p>            linux涓?#37722;?#37837;蜂篃?#20824;缂?#29831;慍++锛宭inux涓婥++缂?#29831;?#37731;?#37828;g锛?#38171;?#38171;岀壒鍒?#37819;愮锛?/p> <p>            C++鐨?#28598;?#37826;?#28000;?#37828;痠ostream?#31497;鏄痠ostream.h鍙?#28598;?#26473;?#38343;鍔犲叆鍛?#37722;嶇闂std锛?#28186;?#28641;?#38171;?/p> <p>            //hello.cpp</p> <p>            #include <iostream></p> <p>            using namespace std;</p> <p>            int main ()</p> <p>            {</p> <p>                  cout<<"helloworld!"<<endl;</p> <p>             }</p> <p> </p> <p>            杩?#37837;?#37813;嶈兘姝?#29999;?#32514;?#29831;?#38171;屽湪璇洰褰?#28051;?#38171;?#32513;?#32468;?#26440;撳叆锛?/p> <p> </p> <p>            # g++ hello.cpp -o hello</p> <p>           </p> <p>            杩?#37837;峰氨鐢?#37812;?#28051;?#37340;hello鐨?#37721;?#37813;?#29723;?#37826;?#28000;?#38171;?#37722;?#37837;?/hello鍛戒护杩?#29723;屽畠</p> <p> </p> <p>鏈?#37826;?#37833;?#38007;狢SDN鍗?#28729;?#38171;岃浆杞?#29831;?#37837;?#37828;?#37713;?#28598;?#38171;歨ttp://blog.csdn.net/Dreamcode/archive/2009/05/11/4166995.aspx</p> <img src ="http://www.67529968.com/lingy/aggbug/293574.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2009-09-02 12:24 <a href="http://www.67529968.com/lingy/archive/2009/09/02/293574.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>Java Class Loaderhttp://www.67529968.com/lingy/archive/2009/08/30/293221.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Sun, 30 Aug 2009 12:54:00 GMThttp://www.67529968.com/lingy/archive/2009/08/30/293221.html绋?#25652;?#32514;?#37714;?#28051;鑸?#38343;缁?#32514;?#26440;?#37510;佺紪璇?#37510;?#26473;?#37818;?#37510;?#37716;?#26462;藉拰杩?#29723;?#37713;犱釜姝?#26976;?#37510;傚湪鎴戜滑鐨?#25652;?#37922;?#28051;?#38171;?#37832;?#28051;浜?#37711;?#37711;?#28000;?#37934;?#37828;?#38343;瑕?#37721;?#28598;?#28003;?#37922;?#38171;屽氨?#22968;杩欎簺浠?#37934;佺紪璇戜负“搴?#8221;鏂?#28000;?#38171;涘湪杩?#37818;?#23005;?#26976;?#28051;?#38171;?#26473;?#37818;?#37731;?#28751;?#28000;庡簱鏂?#28000;?#37721;栧?#26945;墍闇鐨?#28000;?#37934;?#38171;?#28598;?#37714;跺埌鐢?#37812;?#37928;?#37721;?#37813;?#29723;?#37826;?#28000;?#28051;?#37510;?#26473;欑搴撶涓?#38344;?#37804;?#25652;?#38171;?#37711;?#37911;?#37904;?#37828;?#37721;?#37813;?#29723;?#37826;?#28000;?#28051;?#37718;呭惈浜?#25652;?#28000;?#37934;?#37928;?#28051;浠?#28729;屾?#23384;嫹璐?#38171;涚己鐐瑰氨鏄?#29722;?#28598;氭浣?#37922;?#28751;变細鏈?#28598;?#28000;?#37712;?#28003;欐嫹璐?#37510;?/p>

涓?#27996;?#37711;?#37832;?#26473;欎釜缂?#37904;?#37721;?#28000;?#38322;?#37922;姩鎬?#26473;?#37818;?#25652;?#37510;?#26473;欎釜?#26882;鍊?#26473;?#37818;?#37731;?#28000;?#28000;?#37828;湪鍙?#37813;?#29723;?#37826;?#28000;?#28051;?#37813;?#28051;?#37837;囧織锛?#29831;?#37828;?#38343;瑕?#28003;?#37922;?#37725;?#27996;涘姩鎬?#26473;?#37818;?#25652;?#38171;?#35120;?#26473;?#29723;?#32459;?#25652;忔椂锛屽姞杞?#37731;?#37837;规嵁杩欎簺鏍囧織?#22968;?#22669;闇鐨勫姩鎬?#26473;?#37818;?#25652;撳姞杞藉埌鍐?#28699;?#37510;?/p>

鍙?#28598;栧湪褰撳墠鐨勭紪绋?#37916;?#28583;?#28051;?#38171;?#28051;鑸?#38318;?#37819;愪緵鏂规?#26337;绋?#25652;忓湪杩?#29723;?#37928;勬椂鍊欐妸鏌愪釜鐗瑰畾鐨勫姩鎬?#26473;?#37818;?#25652;撳姞杞?#39582;?#26473;?#29723;?#38171;屼篃鍙?#28000;?#28751;?#37711;?#37719;歌浇锛?#28186;?#28641;俉in32鐨凩oadLibrary()&FreeLibrary()?#25328;Posix鐨刣lopen()&dlclose()锛?#37510;?#26473;欎釜鍔熻兘琚?#39582;挎?#28056;湴鐢?#27996;庡湪绋?#25652;?#26473;?#29723;屾椂鍒?#37831;?#37826;?#37836;愪簺鍔熻兘妯?#37735;?#37812;?#38000;?#37828;?#32459;?#25652;?#28598;?#29785;?#37510;?/p>

What is ClassLoader?

涓庢櫘閫?#32459;?#25652;忎笉鍚?#37928;?#37828;?#38171;孞ava绋?#25652;?#38171;坈lass鏂?#28000;?#38171;夊?#26421;笉鏄?#37832;?#37734;?#37928;?#37721;?#37813;?#29723;?#32459;?#25652;?#37510;?#35120;?#26473;?#29723;孞ava绋?#25652;忔椂锛?#26851;栧厛杩?#29723;孞VM锛圝ava铏氭嫙鏈?#38171;?#38171;岀劧鍚?#37712;嶆妸Java class鍔?#26462;藉埌JVM閲?#28598;?#26473;?#29723;?#38171;?#29840;?#29840;?#37716;?#26462;絁ava class鐨勮繖閮?#37714;嗗氨鍙?#37707;欳lass Loader銆?/p>

JVM鏈?#38892;?#37718;呭惈浜?#28051;?#37340;ClassLoader绉?#28051;築ootstrap ClassLoader锛屽拰JVM涓鏍?#38171;孊ootstrap ClassLoader鏄?#37922;?#37832;?#37734;?#28000;?#37934;?#28729;?#37916;?#37928;?#38171;屽畠璐?#29840;?#37716;?#26462;?#37837;稿績Java Class锛?#37719;虫墍鏈塲ava.*寮澶?#37928;勭被锛?#37510;?#37721;?#28598;朖VM杩樹細鎻愪緵涓釜ClassLoader锛屽?#20903;滑閮?#37828;?#37922;Java璇?#29815;缂?#37712;?#37928;?#38171;?#37922;盉ootstrap ClassLoader鍔?#26462;?#38171;?#37711;?#28051;璄xtension ClassLoader璐?#29840;?#37716;?#26462;?#37813;?#28766;?#37928;凧ava class锛?#28186;?#28641;傛墍鏈塲avax.*寮澶?#37928;勭?#35826;拰瀛?#37824;惧湪JRE鐨別xt?#27952;褰?#28051;?#37928;勭被锛?#38171;孉pplication ClassLoader璐?#29840;?#37716;?#26462;?#25652;?#37922;?#32459;?#25652;忚嚜韬?#37928;勭被銆?/p>

When to load the class?

浠涔堟椂鍊橨VM?#32048;浣?#37922;ClassLoader鍔?#26462;?#28051;?#37340;绫?#37723;紵褰?#28003;?#28003;?#37922;java鍘?#37813;?#29723;?#28051;?#37340;绫?#38171;孞VM浣?#37922;Application ClassLoader鍔?#26462;?#26473;欎釜绫?#38171;涚劧鍚庡鏋?#32491;籄寮?#37922;?#27996;?#32491;B锛屼笉绠?#37828;?#37929;?#37818;?#23534;?#37922;?#26473;?#37828;?#37922;Class.forName()寮?#37922;?#38171;孞VM灏变細鎵惧埌鍔?#26462;?#32491;籄鐨凜lassLoader锛屽苟鐢?#26473;欎釜ClassLoader鏉?#37716;?#26462;?#32491;B銆?/p>

Why use your own ClassLoader?

浼?#28052;JVM鑷?#38892;?#37928;凜lassLoader宸?#32513;忚冻澶?#27996;?#38171;?#28051;?#28000;涔?#37812;戜滑杩?#38343;瑕?#37714;涘缓鑷繁鐨凜lassLoader鍛紵

鍥?#28051;JVM鑷?#29999;?#37928;凜lassLoader鍙?#37828;?#37811;?#23536;?#28000;?#37832;?#37734;?#37826;?#28000;?#32495;荤粺鍔?#26462;?#37837;囧噯鐨刯ava class鏂?#28000;?#38171;?#28641;?#37835;滅紪鍐欎綘鑷繁鐨凜lassLoader锛?#28003;?#37721;?#28000;?#37707;氬埌锛?br /> 1锛夊湪鎵?#29723;岄潪缃?#28103;?#28000;?#37934;?#28052;嬪墠锛岃嚜?#23017;楠?#29831;佹暟瀛?#32475;?#37722;?br /> 2锛夊姩鎬佸湴鍒涘缓绗?#37722;?#37922;?#37812;风?#29808;畾闇瑕?#37928;勫畾鍒?#37718;?#37835;勫?#34425;被
3锛?#28000;?#37911;瑰畾鐨勫?#28888;墍鍙栧緱java class锛?#28186;?#28641;傛暟鎹?#25652;?#28051;?br /> 4) 绛?#32475;?/p>

浜嬪疄涓?#35120;?#28003;?#37922;Applet鐨勬椂鍊?#38171;屽氨鐢埌浜?#37911;瑰畾鐨凜lassLoader锛屽洜涓?#26473;欐椂闇瑕?#28000;庣綉缁?#28051;?#37716;?#26462;絡ava class锛屽苟涓旇?#20345;?#29025;?#27977;鍏?#37928;?#28729;夊叏淇?#37805;?#37510;?/p>

?#27952;鍓?#37928;?#25652;?#37922;?#37832;?#37716;?#37731;?#28598;?#38318;?#28003;?#37922;?#27996;咰lassLoader鎶鏈?#38171;?#37719;?#28003;?#28003;犱笉闇瑕?#37714;涘缓鑷繁鐨凜lassLoader锛屼簡瑙?#37711;跺?#29114;?#21973;篃鏈夊姪浜?#37831;?#28610;?#37734;?#38318;讲鑷繁鐨?#25652;?#37922;?#37510;?nbsp;

ClassLoader Tree & Delegation Model

褰?#28003;犲喅?#30078;鍒涘缓浣?#38007;繁鐨凜lassLoader?#26882;锛?#38343;瑕佺户鎵縥ava.lang.ClassLoader鎴?#38000;呭畠鐨?#28699;愮被銆傚湪瀹炰?#23338;寲姣忎釜ClassLoader瀵硅薄?#26882;锛?#38343;瑕?#37816;囧畾涓?#37340;鐖?#28725;硅薄锛?#28641;?#37835;滄病鏈?#37816;囧畾鐨?#29831;?#38171;?#32495;荤粺鑷姩鎸囧畾ClassLoader.getSystemClassLoader()涓虹埗瀵硅薄銆?#28641;?#28051;嬪浘锛?/p>

?#28266;Java 1.2鍚?#38171;宩ava class鐨?#37716;?#26462;?#38322;?#37922;墍璋?#37928;勫鎵樻寮?#38171;圖elegation Modle锛?#38171;屽綋?#30367;鐢?#28051;?#37340;ClassLoader.loadClass()鍔?#26462;?#28051;?#37340;绫?#37928;勬椂鍊?#38171;屽皢閬?#23536;?#28000;?#28051;?#37928;勬楠?#38171;?br /> 1锛夋?#29025;杩欎釜绫?#37828;惁宸?#32513;?#29722;?#37716;?#26462;?#26473;?#37833;?#27996;嗭紵
2锛夊鏋?#26473;樻病鏈夊姞杞?#38171;岃皟鐢?#37910;?#28725;硅薄鍔?#26462;?#29831;?#32491;?br /> 3锛夊鏋滅埗瀵硅薄鏃犳硶鍔?#26462;?#38171;岃皟鐢?#37832;?#28725;硅薄鐨刦indClass()鍙栧緱杩欎釜绫?#37510;?/p>

?#22669;浠?#35120;?#37714;涘缓鑷繁鐨凜lass Loader?#26882;锛?#37721;?#38343;瑕?#38322;嶈浇findClass()杩欎釜鏂规硶銆?/p>

Unloading? Reloading?

褰?#28051;?#37340;java class琚?#37716;?#26462;藉埌JVM涔?#37722;?#38171;屽畠鏈夋病鏈?#37721;兘琚?#37719;歌浇鍛紵鎴戜滑?#29025;閬Win32鏈塅reeLibrary()鍑芥暟锛孭osix鏈塪lclose()鍑芥暟鍙?#28000;?#29722;皟鐢?#37833;?#37719;歌浇鎸囧畾鐨勫姩鎬?#26473;?#37818;?#25652;?#38171;?#28003;?#37828;疛ava骞舵病鏈?#37819;愪緵涓?#37340;UnloadClass()鐨勬?#35268;硶鏉?#37719;歌浇鎸囧畾鐨勭被銆?/p>

?#28266;Java涓?#38171;宩ava class鐨?#37719;歌?#25106;粎浠?#37828;?#28051;绉?#28725;?#32495;荤粺鐨勪?#27194;寲锛?#37832;夊姪浜?#37713;?#28751;?#25652;?#37922;?#28725;?#37712;?#28699;?#37928;勫崰鐢?#37510;?#37827;劧鏄?#28051;绉?#28028;樺寲鏂规硶锛岄偅涔?#28751;?#28729;?#37711;?#37828;疛VM鑷?#29723;屽喅?#30078;濡?#28003;曞疄鐜?#38171;屽?#31551;ava寮鍙戜汉鍛?#37833;?#29831;?#37828;?#28729;?#37711;?#38315;?#37828;?#37928;?#37510;?/p>

?#28266;浠涔堟椂鍊欎竴?#37340;java class/interface?#32048;琚?#37719;歌浇鍛紵Sun鍏?#37721;?#37928;?a href="http://java.sun.com/docs/books/jls/unloading-rationale.html">?#24107;璇?/a>鏄?#26473;欎箞璇?#37928;?#38171;?class or interface may be unloaded if and only if its class loader is unreachable. Classes loaded by the bootstrap loader may not be unloaded."

浜嬪疄涓?#37812;戜滑鍏冲績鐨勪笉鏄?#28641;?#28003;?#37719;歌浇绫?#37928;?#38171;?#37812;戜滑鍏冲績鐨?#37828;?#28641;?#28003;?#37831;?#37826;板凡缁?#29722;?#37716;?#26462;戒簡鐨勭被浠庤?#37831;?#37826;?#25652;?#37922;?#37928;?#37716;熻兘銆侸SP鍒?#37828;?#28051;?#37340;闈?#29999;?#37711;稿瀷鐨勪緥瀛?#38171;?#28641;?#37835;?#28051;?#37340;JSP鏂?#28000;?#29722;?#37831;存敼浜?#38171;屽簲鐢?#37832;?#37716;?#37731;?#37714;?#38343;瑕佹妸鏇存敼鍚?#37928;凧SP閲?#37826;扮紪璇?#38171;岀劧鍚庡姞杞?#37826;?#37922;?#37812;?#37928;勭被鏉?#37725;?#25652;?#37722;?#32513;?#37928;?#29831;锋眰銆?/p>

鍏?#28729;?#28051;?#37340;宸?#32513;?#37716;?#26462;?#37928;勭被鏄?#37827;犳硶琚?#37831;?#37826;?#37928;?#38171;?#28641;?#37835;?#28003;?#29831;曞浘鐢?#37722;?#28051;?#37340;ClassLoader鍐嶆鍔?#26462;?#37722;?#28051;?#37340;绫?#38171;屽氨?#32048;寰楀埌寮?#29999;?#38171;java.lang.LinkageError: duplicate class definition锛?#38171;?#37812;戜滑鍙兘澶?#38322;?#37826;?#37714;涘缓涓?#37340;鏂?#37928;凜lassLoader瀹炰緥鏉?#37712;嶆鍔?#26462;?#37826;?#32491;?#37510;?#38007;?#27996;庡師鏉?#23480;?#32513;?#37716;?#26462;?#37928;勭被锛屽紑鍙戜汉鍛樹笉蹇呭?#33636;瀹?#38171;屽洜涓?#28729;?#37721;兘杩?#37832;夊?#28848;緥姝湪琚?#28003;?#37922;?#38171;?#37721;?#29781;佺浉鍏?#37928;?#28729;炰緥閮?#29722;?#37712;?#28699;樺洖鏀朵簡锛岄偅涔圝VM灏变細?#28266;閫?#35120;?#37928;勬椂鍊欐妸?#31497;?#32048;鍐?#28003;?#37922;?#37928;勭被鍗歌浇銆?/p>

]]>
TOMCAT婧愮爜鎬荤粨涓http://www.67529968.com/lingy/archive/2009/08/30/293216.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Sun, 30 Aug 2009 12:05:00 GMThttp://www.67529968.com/lingy/archive/2009/08/30/293216.html棣栧厛?#31497;寰椾笉璇?#26473;欎釜绫籵rg.apache.tomcat.util.net.JIoEndpoint锛屽畠璐?#29840;墍鏈?#37928;凾CP璇锋眰杩?#37818;?#38171;屽疄鐜?#27996;?#28051;?#37340;鏈?#37716;?#37731;?#22959;?#23534;?#38171;?#37722;?#37922;?#28051;?#37340;鍚?#37721;?#37929;?#37722;嚎绋?#38171;?#29840;?#29840;?#37818;?#37824;跺埌鏉?#37928;剆ocket锛岀劧鍚?#28000;庣嚎绋?#23033;?#28051;?#37721;?#37713;哄搷搴?#37928;剋orker锛?#37813;?#32513;檞orker杩?#29723;?#28598;勭悊锛岃嚜?#32321;缁?#32513;?#37929;?#37722;?#37510;?#37711;?#23046;worker鏄?#28051;?#37340;璐?#29840;?#28598;勭悊socket鐨?#28051;?#37340;?#22158;绋?#38171;屽氨鏄?#28729;?#29999;潃鐢?#37812;?#37928;?#29831;锋眰寮濮嬭繘?#21446;Tomcat涓栫晫鐨?#38171;岄?#27199;鐨剋orker鎬?#37711;?#37832;?00?#37340;锛?#37719;?#38171;?#37832;澶?00?#37340;?#22158;绋?#37510;?#35120;?#28598;勭?#21975;畬涓?#37340;璇锋眰鐨勬椂鍊?#38171;?#26473;欎釜?#22158;绋嬪?#26421;笉?#32048;閿姣?#38171;岃?#37828;?#26473;涘叆wait闃诲锛?#26473;欎釜?#22158;绋?#37928;?#28725;硅薄涔熶笉?#32048;閿姣?#38171;?#37828;?#26473;涘叆浜?#28051;?#37340;鏍?#38322;岄潰锛屽搴攚orkstack閭釜?#26271;鎹粨鏋?#37510;?#23011;?#35120;?#37818;?#37824;剁嚎绋?#37815;垮埌涓?#37340;socket鐨勬椂鍊?#38171;屽?#21342;厛浠?#37837;?#38322;岄潰鎷?#37713;?#28051;?#37340;宸?#37832;?#37928;勭嚎绋?#28725;硅薄锛岀劧鍚庡氨鍒?#37922;?#29831;?#28725;硅薄鐨刟ssign鏂规硶锛屽皢杩欎釜socket缁?#28729;?#38171;屽?#24816;皟鐢notify閲?#37826;板?#21835;杩欎釜worker鐨?#28598;勭?#21977;嚎绋?#37510;備互鍚?#37812;戜滑鍋氬?#24531;瀷鏈?#37716;?#37731;?#37928;勬椂鍊?#38171;?#37721;?#28000;?#37706;熼壌瀹?#37928;?#28729;?#37916;?#37826;?#23534;?#37510;傛?#28266;鐮旂澶氱嚎绋?#37928;勬湅鍙?#38171;?#26473;欎釜绫荤粷瀵?#29825;?#28003;?#37721;?#28000;?#28699;?#37928;勯?#35120;?#38171;?/p>

?#27977;瀵?#25652;?#37928;勮繕鏈?#28051;?#37340;org.apache.tomcat.util.net.NioEndpoint锛?#26473;欎釜鍜屽墠?#28528;閭釜鍔熻兘宸笉澶?#38171;?#28003;?#37828;?#37922;?#27996;哊IO鍖?#38322;?#37928;凙PI锛?#37832;?#28051;?#37340;鏈澶?#37928;勫尯鍒?#28751;?#37828;?#38171;?#37818;?#37824;剁嚎绋?#37818;?#37824;?#28051;?#37340;socket涔?#37722;?#38171;?#37721;?#38003;戒細灏?#26473;欎釜socket?#21403;鏀惧叆缂?#28699;樻睜锛岀劧鍚巜orker浠庢睜閲岄潰鎷縮ocket鍘?#28598;勭悊锛?#23011;?#37715;嶉潰閭釜绫荤湅璧?#37833;?#37716;熻兘?#25328;鎬兘閮戒細鎻?#37719;囧緢澶?#38171;屼笉杩?#28000;?#37934;?#29723;?#37832;?K澶?#38171;岀浉褰?#28598;?#37833;?#38171;?#29825;?#29825;笉澶熺?#24807;y锛?#37832;夊叴瓒?#37721;?#28000;?#37720;荤?#26050;涓?#37510;?/p>

org.apache.tomcat.util.buf.MessageBytes锛?#26473;?#37828;?#28051;?#37340;鎺?#26473;?#25652;?#28766;?#37928;?#28699;?#32471;?#28051;?#28598;勭悊绫?#38171;?#28051;?#28000;涔?#29831;?#37828;?#37818;?#26473;?#25652;?#28766;?#38171;?#37828;?#37733;?#28051;簊ocket鎺?#37824;?#26473;?#37833;?#37928;?#38318;?#37828;?#28699;楄妭绫诲瀷锛岃宩ava鐢?#37928;?#37828;痗har鎴?#38000;匰tring锛?#26473;欎箣闂?#37928;勮浆?#23858;娑?#37721;婂埌缂?#37934;?#38338;?#26864;樺拰鎬兘闂?#26864;?#38171;屾墍浠?#37713;?#37828;痵ocket鏀?#26473;?#37833;?#37928;?#28103;?#37805;?#38171;?#37711;?#38318;?#38318;?#37922;?#26473;欎釜绫?#29723;?#32448;?#38171;?#37721;?#37832;夊綋瑕?#26440;?#37713;?#28699;?#32471;?#28051;?#37928;勬椂鍊?#38171;?#37813;嶄細灏?#38322;岄潰鐨?#28699;楄妭杩?#29723;岃浆?#23858;锛屽疄鐜?#28051;绉嶅欢杩?#37716;?#26462;?#37928;勬妯?#23534;?#38171;?#29722;玊omcat搴?#28766;傛墍浣?#37922;?#37928;凴equest绫?#38171;屽氨鏄?#28598;?#38322;?#28003;?#37922;?#27996;?#26473;欎釜绫?#37833;?#28699;?#37824;炬暟鎹?#37510;?#37812;戜滑鏉?#28751;?#28751;忕瑙?#28051;涓?#38171;孯equest绫?#38171;?/p>

  1. private MessageBytes methodMB = MessageBytes.newInstance();
  2.     private MessageBytes unparsedURIMB = MessageBytes.newInstance();
  3.     private MessageBytes uriMB = MessageBytes.newInstance();
  4.     private MessageBytes decodedUriMB = MessageBytes.newInstance();
  5.     private MessageBytes queryMB = MessageBytes.newInstance();
  6.     private MessageBytes protoMB = MessageBytes.newInstance();
  7.  
  8.     // remote address/host
  9.     private MessageBytes remoteAddrMB = MessageBytes.newInstance();
  10.     private MessageBytes localNameMB = MessageBytes.newInstance();
  11.     private MessageBytes remoteHostMB = MessageBytes.newInstance();
  12.     private MessageBytes localAddrMB = MessageBytes.newInstance();
  13.     
  14.     private MimeHeaders headers = new MimeHeaders();

鎴?#29825;?#28598;?#28729;朵細瑙夊緱锛?#37835;勯?#37713;?#26473;欎箞澶?#37928;勭被锛?#37804;?#38003;戒細楂樺埌鍝?#38322;屽幓锛?#37711;?#28729;炰笉鏄?#26473;?#37837;?#37928;?#38171;屼笉鍋?#37928;?#37835;勯犲?#23684;攢姣?#28725;硅薄鐨勭?#32048;鎹?#38000;楃浉褰?#37928;勬兘锛?#28003;?#37828;?#28051;?#37340;瀵硅薄琚?#37835;勯?#37713;?#37833;?#38171;?#37721;?#28000;?#38322;?#28598;?#37714;?#37922;?#38171;岄偅灏辩浉褰撳?#23680;浜?#38171;?#26473;欎釜绫诲氨鏄?#28641;傛鐨勮璁?#38171;?#37711;?#28051;?#37832;?#28051;?#37340;鍥?#37824;?#29863;勬簮鐨勬?#35268;硶锛?#37721;玶ecycle()锛?#26473;欎釜鏂规硶鍙?#28000;?#23059;呯閲岄潰鐨勬暟缁?#38171;屾?#21615;閲岄潰鐨?#28725;硅薄锛岃屼笉?#32048;閿姣?#38007;繁鏈?#38892;?#38171;屽洜涓?#28003;?#37922;?#28729;?#37928;?#28725;硅薄锛?#37721;?#29781;佽皟鐢recycle锛?#28000;?#37722;?#37721;?#37721;?#28000;?#38322;?#28598;?#28003;?#37922;?#27996;?#37510;?/p>

MessageBytes鍏?#28729;?#37712;呯疆浜??#37340;閲?#29781;?#37928;勭被锛宱rg.apache.tomcat.util.buf.ByteChunk?#25328;org.apache.tomcat.util.buf.CharChunk锛?#26473;??#37340;绫?#29999;?#37812;戜滑鍥炲埌浜咰?#26882;浠?#38171;?#28051;?#28000;涔?#26473;欎箞璇达紵鍥?#28051;?#28729;冪畝鐩?#28751;?#37828;?#28051;?#37340;瀛?#32471;?#28051;?#28598;勭悊绫?#38171;?#28051;浜涚溂鐔?#37928;勭?#26945;硶鍏?#38318;?#37828;犲叆鐪?#29999;?#38171;?#23011;?#28641;?#28699;?#32471;浆鍖?#38320;嶇?#26945;硶锛宨ndexOf锛宻tartsWith锛?#37714;?#37826;?#28699;?#32471;浆鏄惁?#27977;绛?#38171;屾煡鎵?#28699;?#32471;?#38171;岀瓑绛?#38171;?#23011;?#28052;婮DK鎻愪緵鐨勬兘鏇?#28610;?#38171;屽姛?#20824;鏇?#23534;?#28598;?#38171;?#26473;?#37721;?#29831;?#29831;?#26473;囦簡锛?#37723;?#37723;?#38171;?/p>

杩?#37832;?#28051;?#37340;瀹?#37922;?#37928;?#37706;?#23536;?#28699;範鐨勬暟鎹粨鏋?#37828;?#38171;宱rg.apache.tomcat.util.buf.Ascii锛?#28641;?#37835;滅煡閬?#29723;?#26937;卞姩鐨勬湅鍙嬩滑锛?#28051;?#30078;瀵?#26473;欎釜绫诲?#22562;?#29112;倝浜?#38171;?#37714;?#37826;?#28598;?#28751;?#37712;欙紵鍒?#37826;?#37828;笉鏄嫳鏂囧崟璇嶏紵鍒?#37826;?#37828;笉鏄?#32460;虹櫧绗紵鍒?#37826;?#37828;笉鏄暟瀛?#38171;屽皢瀛楄妭绫诲?#23341;浆?#23858;涓篿nt銆乴ong绫诲瀷锛?#28598;?#28751;?#37712;欒浆?#23858;锛岀瓑绛?#37510;?#26473;欎簺閮?#37828;?#28598;?#28699;?#29825;?#32480;?#37832;?#29831;?#32459;?#37928;?#29831;?#37722;?#32513;冧範棰?/p>

]]>
濡?#28003;?#28598;勭悊HTTP POST/GET璇锋眰http://www.67529968.com/lingy/archive/2009/08/29/293078.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Sat, 29 Aug 2009 03:56:00 GMThttp://www.67529968.com/lingy/archive/2009/08/29/293078.html 銆銆銆銆[鍏?#28766;忔煡?#28229;鍏?#37826;?/strong>]
Servlet閫?#26473;?#28051;嬮潰鐨勬?#35268;硶鏉?#37819;愪緵鏈?#37716;?#38171;?
  • 瀹?#37916;皊ervice鏂规硶銆?br />
  • 瀹?#37916;HttpServlet鐨刣oMethod鏂规硶锛坉oGet銆乨oDelete銆乨oOptions銆?doPost銆乨oPut銆乨oTrace锛?#37510;?/li>
    閫?#29999;?#38171;宻ervice鏂规硶鐢?#37833;?#28000;庡鎴?#29831;锋眰锛坮equest锛?#28051;?#37819;?#37721;?#28103;?#37805;?#38171;?#29825;?#38338;?#37813;?#28766;?#29863;勬簮锛屽?#36346;熀浜?#28051;婇潰鐨?#28103;?#37805;?#37819;愪?#28056;搷搴?#38171;坮esponse锛?#37510;?

    瀵?#27996;嶩TTP Servlets锛屾纭?#37819;愪?#28056;搷搴?#37928;勮繃绋?#37828;?#26851;栧厛濉?#37712;?#37725;?#25652;?#38171;坮esponse锛?#37928;?#28598;?#28103;?#37805;?#38171;岀劧鍚?#28000;庡搷搴?#38171;坮esponse锛?#28051;?#23536;楀埌杈?#37713;?#23092;?#38171;?#37832;鍚?#37722;戣緭鍑?#23092;?#28051;?#37712;欏叆鍐呭淇?#37805;?#37510;傚搷搴?#38171;坮esponse锛?#28598;?#28103;?#37805;?#36423;?#26916;?#37832;?#21403;璁?#32515;?#37510;?#28051;嬮潰灏?#37819;?#26473;?#28641;?#28003;?#28000;?#29831;锋眰锛坮equest锛?#28051;?#38014;?#23536;?#28103;?#37805;拰?#39559;鐢烪TTP鍝?#25652;?#38171;坮esponse锛?#37510;?

    
  • 鍙栧?#26944;鎴?#32468;?#29831;锋眰
        涓?#37340;HttpServletRequest瀵硅薄鎻愪?#28056;埌杈HTTP 澶?#38318;暟鎹?#38171;屼篃鍏?#29825;?#28003;犺幏鍙栧鎴?#32468;?#37928;勬暟鎹?#37510;?#37804;?#37837;疯幏鍙?#26473;欎簺?#26271;鎹?#37721;栧喅浜嶩TTP绔?#29831;锋眰鏂规硶銆備笉绠?#37922;?#28000;?#28003;HTTP鏂?#23534;?#38171;?#28003;?#38318;?#37721;?#28000;?#37922;?getParameterValues鏂规硶杩?#37733;?#37911;瑰畾鍚嶇鐨?#37721;傛暟鍊?#37510;?#28725;?#27996;?#37922;?HTTP GET 璇锋眰鐨勬柟寮?#38171;?#26473;欎釜getQueryString鏂规硶灏嗕細杩?#37733;?#28051;?#37340;鍙?#28000;?#37922;?#37833;?#37714;?#37835;?#37928;?#37706;?#37510;?

        瀹?#37812;?#32468;?#29831;锋眰锛坮equest锛夊?#21613;惈浜?#28000;庡鎴?#32468;?#28028;?#38315;掑埌Servlet鐨勬暟鎹?#37510;傛墍鏈?#37928;?#29831;锋眰锛坮equest锛?#38318;?#28729;?#37916;?#27996;哠ervletRequest鎺?#37721;?#37510;?#26473;欎釜鎺?#37721;畾涔?#27996;?#28051;浜?#37826;规?#26337;闂?#28051;嬮潰鐨?#28103;?#37805;?#38171;?#28641;?#29723;?4-1?#22669;绀?#37510;?

    琛?4-1  ServletRequest鎺?#37721;?#37826;规硶
                绫??#28727; 鎻?杩?                         瀵?搴?鏂??#30838;
                鍙傛暟锛?#37922;?#37833;湪瀹?#37812;?#32468;拰Servlet涔?#38338;?#28028;?#38315;?#28103;?#37805;?getAttribute(String name)
                getAttributeNames()
                getInputStream()
                getParameter(String name)
                getParameterMap()
                getParameterNames()
                getParameterValues(String name)
                瀵硅薄鍊?#28766;?#37804;?#38171;?#37922;?#37833;湪Servlet瀹?#37731;拰Servlet
                涔?#38338;?#38171;?#37812;?#38000;呭崗浣?#37928;凷ervlet涔?#38338;?#28028;?#38315;?#28103;?#37805;?    removeAttribute(String name)
                setAttribute(String name, Object o)
                鏈夊叧璇锋眰浣?#37922;?#37928;?#37719;?#29825;?#28103;?#37805;?#38171;?
                瀹?#37812;?#32468;拰鏈?#37716;?#37731;湪璇锋眰涓?#37928;勮皟鐢?   getContentLength()
                getContentType()
                getProtocol()
                getReader()
                getRealPath(String path)
                getRemoteAddr()
                getRemoteHost()
                getRequestDispatcher(String path)
                鏈夊叧璇锋眰浣?#37922;?#37928;?#37719;?#29825;?#28103;?#37805;?#38171;?
                瀹?#37812;?#32468;拰鏈?#37716;?#37731;湪璇锋眰涓?#37928;勮皟鐢?      getScheme()
                getServerName()
                getServerPort()
                isSecure()
                鏈夊叧localization鐨?#28103;?#37805;?       getCharacterEncoding()
                getLocale()
                getLocales()
                setCharacterEncoding(String env)


        涓嬮潰鐨?#28000;?#37934;?#23048;?#32448;鸿寖浜?#28641;?#28003;?#28003;?#37922;request涓?#37928;勬?#35268;?#26337;幏寰楀鎴?#32468;?#28103;?#37805;?#37510;?

    Enumeration params = request.getParameterNames();
                String paramName = null;
                String[] paramValues = null;
                while (params.hasMoreElements()) {
                paramName = (String) params.nextElement();
                paramValues = request.getParameterValues(paramName);
                System.out.println("\nParameter name is " + paramName);
                for (int i = 0; i < paramValues.length; i++) {
                System.out.println(", value " + i + " is " + paramValues[i].toString());
                }
                }


        HTTP Servlets浣?#37922;HTTP request瀵硅薄锛圚ttpServletRequest锛?#38171;屽畠鍖呭惈浜唕equest URL銆丠TTP澶?#28103;?#37805;?#37510;佹煡璇?#28699;?#32471;?#28051;?#38171;岀瓑绛?#37510;侶TTP request URL 鍖呮嫭鍑犱釜閮?#37714;?#38171;?br />     http://: ?

        涓鑸?#37807;呭喌涓?#38171;?

    requestURI = contextPath + servletPath + pathInfo
                Context path锛?#38315;?#26473;getContextPath鏂规?#26337;幏寰?#37510;?
                Servlet Path锛?#38315;?#26473;getServletPath鏂规?#26337;幏寰?#37510;?
                PathInfo锛?#38315;?#26473;getPathInfo鏂规?#26337;幏寰?#37510;?/ccid_code>


        濡?#29723;?4-2?#22669;绀?#37510;?

    琛?4-2  ?#30718;寰?#37928;?#28725;?#25652;?
                Request Path	            Path Elements
                /catalog/help/feedback.jsp	ContextPath: /catalog ServletPath:
                /help/feedback.jsp PathInfo: null


        
  • 鎻愪緵HTTP鍝?#25652;?
        鍝?#25652;?#38171;坮esponse锛夊?#21613;惈浜嗗湪鏈?#37716;?#37731;?#37724;屽鎴?#32468;?#28052;?#38338;?#28028;?#38315;?#37928;勬暟鎹?#37510;傛墍鏈?#37928;勫搷搴?#38171;坮esponse锛?#38318;?#28729;?#37916;?#27996;哠ervletResponse鎺?#37721;?#37510;?#26473;欎釜鎺?#37721;畾涔?#27996;?#28051;浜?#37826;规硶鎻愪?#28058;粰寮鍙戜汉鍛?#28003;?#37922;?#38171;?#28641;?#29723;?4-3?#22669;绀?#37510;?

    琛?4-3  ServletResponse鎺?#37721;?#37826;规硶
                绫??#28727; 鎻?杩?                          瀵?搴?鏂??#30838;
                鑾?#23536;楀悜瀹?#37812;?#32468;?#37721;戦佹暟鎹?#37928;勮緭鍑?#23092;? 鍙戦?#28699;?#32471;?#23092;?#38171;歡etWriter()
                鍙戦?#28699;楄妭娴?#38171;歡etOutputStream()
                鎸囩?#21700;搷搴旇繑鍥?#37928;?#37712;呭绫诲瀷锛?#28186;?#28641;?#38171;歵ext/html锛?
                宸?#32513;?#23049;?#37712;?#37928;?#37712;呭绫诲瀷鍚嶇淇?#28699;樺湪IANA
                锛圛nternet Assigned Numbers Authority锛?setContentType(java.lang.String type)
                鎸囧嚭鏄惁鏄?#32514;?#37712;?#26440;?#37713;?#37510;傞?#27199;鎯呭喌涓?#37712;欏叆杈?#37713;?#37928;?
                鍐呭琚?#32468;?#37719;?#37721;戦佸埌瀹?#37812;?#32468;?#37510;?#28003;?#37922;?#32514;?#37712;?#37722;?#37712;欏叆杈?#37713;?#37928;?#37712;呭?#29808;厛
                ?#31497;鍙戦佸埌瀹?#37812;?#32468;?#38171;?#26473;?#37837;Servlet鏈?#37831;?#28598;?#37928;勬椂闂?#29825;?#32515;浉搴?#37928;?
                鐘?#37804;佺?#20344;拰澶?#28103;?#37805;?#38171;?#37812;?#38000;呰浆绉诲埌鍏?#28000;?#37928;刉eb璧勬簮	 flushBuffer()
                getBufferSize()
                isCommitted()
                reset()
                resetBuffer()
                setBufferSize(int size)
                setContentLength(int len)
                璁?#32515;localization淇?#37805;?            getCharacterEncoding()
                getLocale()
                setLocale(java.util.Locale loc)


        HTTP response绫?#38171;圚ttpServletResponse锛?#37832;?#28051;浜?#28000;?#29723;HTTP澶?#28103;?#37805;?#37928;勫煙锛?br />     
  • 鐘?#37804;佺爜鐢?#37833;?#37816;囧?#21700;搷搴?#38171;坮esponse锛?#28598;?#29840;?#37928;勫師鍥?#37510;?


        
  • Cookies?#28266;瀹?#37812;?#32468;?#28699;樺偍搴?#37922;浉鍏?#37928;?#28103;?#37805;?#38171;?#37832;夋椂cookies鐢?#37833;?#32513;存姢?#25328;鏍?#29831;?#37922;?#37812;?#37928;剆ession銆?

        Servlet棣栧厛璁?#32515;?#37725;?#25652;?#38171;坮esponse锛?#28598;?#28103;?#37805;?#38171;屽?#21614;嫭鍝?#25652;?#38171;坮esponse锛?#37928;?#37712;呭绫?#37714;?#37724;岀紦鍐?#37718;?#28598;?#28751;?#38171;岀劧鍚庡湪doGet鏂规硶涓?#28000;庡搷搴?#38171;坮esponse锛夎幏寰桺rintWriter 锛?#37832;鍚?#37722;戣緭鍑?#28051;?#37712;欏叆HTML浠?#37934;?#38171;岃皟鐢close()鏂规硶鎻愪氦杩?#23046;?#28725;瑰鎴?#32468;?#37928;勫搷搴?#38171;坮esponse锛?#37510;傜?#40511;寖浠?#37934;?#28641;?#28051;?#38171;?

    public void doGet (HttpServletRequest request,
                HttpServletResponse response)
                throws ServletException, IOException
                {
                // 璁?#32515;?#28598;?#28103;?#37805;?
                response.setContentType("text/html");
                response.setBufferSize(8192);
                PrintWriter out = response.getWriter();
                // 鍚憆esponse涓?#26440;?#37713;?
                out.println("<html>" +
                "<head><title>+
                messages.getString("TitleBookDescription")
                +</title></head>");
                ...
                out.println("</body></html>");
                // 鍏?#38338;?#26440;?#37713;?#23092;?
                out.close();
                }


  • ]]>
    TOMCAT婧愮爜鍒?#37835;?娑?#37805;?#28598;勭悊)http://www.67529968.com/lingy/archive/2009/08/26/292716.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Wed, 26 Aug 2009 12:53:00 GMThttp://www.67529968.com/lingy/archive/2009/08/26/292716.html1.  鎴戜滑浠?#28051;?#37340;鍏蜂綋鐨勪緥瀛?#38171;?#37833;?#29882;熻釜TOMCAT?#28229;?#28229;瀹?#37828;?#28641;?#28003;曟妸Request骞?#37832;鍚?#27996;?#32513;?/span>Wrapperhttp://localhost:8080/web/login.jsp閮?#37828;?#28000;?/span>tomcat4  2鍓?#37832;?Request鐨刡orn.

    http://localhost:8080/web/login.jsp    ok, 鎴戜滑?#28266; tomcat鐨?#26916;?#28766;?#28729;?#37731;?- StandardEngin http://localhost:8080/web/login.jsp1. run(): 536, java.lang.Thread, Thread.java

    4.        processConnection():  549

    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler, Http11Protocol.java

                      http protocol parser

          5. Process(): 781, org.apache.coyote.http11.Http11Processor, Http11Processor.java

              http request processor

           6. service(): 193, org.apache.coyote.tomcat4.CoyoteAdapter,CoyoteAdapter.java

             adapter

           7. invoke(): 995, org.apache.catalina.core.ContainerBase, ContainerBase.java

       StandardEngin

        2. 鍚姩?#22158;绋?#23033;?

        4. ?#22968;8080绔?#37721;?#28028;?#26473;?#37833;?#37922;httpd鍗?#29825;?#28751;佽鐨勬暟鎹?#38171;?#29785;?#37835;?#37812;怰equest?#25328;Response瀵硅薄銆?/span>

    鏉?#28598;勭悊request

    閲岄潰锛?鍙堜細call CoyoteAdapter7鍋?#37837;稿績鐨?#28598;勭?#21975;伐浣?#27996;?#37510;?/span>

        Request?#28266;鍚勪釜瀹?#37731;?#38322;岄潰鐨勭?#25358;澶嚧鏄?#26473;?#37837;蜂竴绉?#37826;?#23534;?#38171;?/span>

        绠?#38316;?#38322;岄潰鍙?#37832;夊鍑犱釜闃闂?#38171;valve锛?#38171;?涓?#38338;?#37922;?#37833;?#26473;囨护Request鐢?#37928;?#37510;?/span>

        璁?#37812;戜滑鏉?#37807;宠薄涓涓?#38171;?/span>

        灏?#37828;?#38315;?#26473;?#26473;欑鏂?#23534;?#38171;?Request 璧?#28729;屼?#21976;墍鏈?#37928;?#28729;?#37731;?#37510;?#38171;?鎰?#29785;?#37832;?#37904;瑰?#24532;秷鍖?#32495;荤粺锛?#37832;鍚?#28051;?#37340;鍦?#37826;规湁鐐瑰儚閭?#38322;~ 锛?/span>

    3.1 StandardEngin 鍋?#27996;?#28051;?#28000;朵簨锛?/span>

    1.   鏄笉鏄?/span>httpservletRequest.

    2    鏄惁鎼?#29999;?#27996;?/span>host header3    鍘?#28598;勭?#21975;畠銆?#38171;?#28051;鑸?#37812;戜滑閮?#37721;?#37832;?#28051;?#37340;host:localhost锛?#37510;?/span>

    鎴戜滑鐨?/span>request杩欎釜閮?#37714;?#37928;勫巻鍙?#28003;?#37723;?#38171;?/span>浜?#37510;?/span>

    3.2 StandardHost 1.   鏄笉鏄?/span>httpservletRequest.

    2.   鏉?#32429;畾鍝釜ContextContext锛?/span>http://localhost:8080/web/login.jsp

    灏?#37828;?/span>Context3.   浜?#38171;岄偅涔?#28751;?#25652;旇?#22968;閭釜Context浠?#32513;?#35120;撳墠?#22158;绋?#27996;?#37510;?/span>

            Thread.currentThread().setContextClassLoader(context.getLoader().getClassLoader());

       灏?#37721;湅寰?#29785;?#37816;囧畾鐨?/span>context鍟?#38171;?/span> jar鑰岀湅?#31497;瑙?/span>tomcat浠涔?/span>Engin鍟?#37510;?/span>杩樺洖鏉?#37510;?/span>

    3.3 StandardContext 1.   鏄笉鏄?/span>httpservletRequest.

    2.   鎰忓浘?#31497;杞?#38171;?#37807;?#29781;?#29825;?#38338;?/span>/meta-inf, /web-inf3.   ?#22476;搴?#37828;?/span>Servlet杩?#37828;?/span>jsp杩?#37828;?#38344;?#37804;?#29863;勬簮鏉喅?#30078;?#22476;搴?#37922;?#37725;?#32457;?/span>Wrapper浜?#37510;?/span>

    4.   锛?/span>OK澶勭悊銆?/span>

     <http://jakarta.apache.org/tomcat/>
       <
    http://www.onjava.com/pub/a/onjava/2003/05/14/java_webserver.html>

     


    浣?#38000;匓log锛?/strong>http://blog.csdn.net/ThomasHuang/
    ?#27977;鍏?#37826;?#32468;?/strong>


    ]]>
    TOMCAT婧愮爜鍒?#37835;?鍚姩妗?#37835;?/title><link>http://www.67529968.com/lingy/archive/2009/08/26/292715.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Wed, 26 Aug 2009 12:49:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2009/08/26/292715.html</guid><description><![CDATA[<table cellpadding="4" width="100%" border="0"> <tbody> <tr> <td height="19"> <table cellspacing="3" cellpadding="3" width="100%" bgcolor="#eeeeee" border="0"> <tbody> <tr> <td><strong><span id="ArticleTitle1_ArticleTitle1_lblTitle">TOMCAT婧愮爜鍒?#37835;?鍚姩妗?#37835;?</span></strong>     閫夋嫨鑷?<a id="ArticleTitle1_ArticleTitle1_AuthorLink" href="http://dev.csdn.net/user/ThomasHuang">ThomasHuang</a> 鐨?Blog </td> </tr> <tr> <td align="center" bgcolor="#003399" height="16"><font color="#ffffff">鍏抽敭瀛?/font></td> <td width="500">  <span id="ArticleTitle1_ArticleTitle1_lblKeywords">tomcat ?#31790;浠?#37934;?婧愮爜 source code architecture</span></td> </tr> <tr> <td align="center" bgcolor="#003399" height="16"><font color="#ffffff">鍑?#28598;?/font></td> <td>  </td> </tr> </tbody> </table> </td> </tr> <tr> <td width="10"></td> <td><span id="ArticleContent1_ArticleContent1_lblContent"> <p>TOMCAT婧愮爜鍒?#37835;?鍚姩妗?#37835;?<br /> 鍓嶈锛?br />    鏈?#37826;?#37828;?#37812;戦槄璇?#27996;員OMCAT婧愮爜鍚?#37928;?#28051;浜涘績寰?#37510;?涓?#29781;?#37828;?#29825;?#29785;TOMCAT鐨勭?#33636;粺妗?#37835;?#38171;?浠?#37721;?#37722;姩娴佺銆傝嫢鏈夐敊婕忎箣澶?#38171;屾暚璇?#37813;?#29831;勬?#22248;暀锛?br /> 寤?#29825;?#38171;?br />    ?#30255;绔烼OMCAT鐨勬鏋?#26473;?#37828;?#23011;旇緝澶?#37833;?#37928;?#38171;?鍗?#37828;?#28000;?#37826;?#28699;?#28051;?#37918;?#29785;?#38171;?鏄笉閭?#28052;?#28729;?#37828;?#37818;?#37819;TOMCAT鐨勬鏋?#37928;?#37510;??#22669;浠?#23536;楀疄璺?#37510;?#28729;?#29882;?#37510;?#37712;?#28729;?#29882;?#37510;?寤?#29825;?#28051;嬭浇涓浠絋OMCAT鐨勬?#24878;爜锛??#30367;璇?#38315;?#26473;?#38171;??#21159;鍚庡崟姝?#29882;熻釜鍏?#37722;姩杩?#32459;?#37510;?濡?#37835;?#37832;変笉鏄?#37927;?#37928;勫湴鏂?#38171;?鍐?#37833;煡闃?#37832;?#37826;?#38171;??#28229;鏄惁?#20824;寰楀埌甯?#37716;?#37510;?鎴戠浉淇?#26473;?#37837;锋晥鏋?#28000;?#37721;?#28699;範閫?#25652;?#38318;戒細濂?#23536;?#28598;?#38171;?br />    <br /> 1. Tomcat鐨勬暣浣撴鏋剁粨鏋?br />    Tomcat鐨勫熀鏈?#22935;?#37835;?#38171;?鍒?#28051;??#37340;灞傛銆?br />    Top Level Elements:<br />     Server<br />     Service   <br />    Connector<br />     HTTP<br />     AJP<br />    Container<br />    Engine<br />      Host<br />    Context<br />    Component  <br />     manager<br />    logger<br />    loader<br />    pipeline<br />    valve<br />          ...<br />    绔欏湪妗?#37835;?#37928;?#26916;?#28766;?#37928;?#37828;疭erver?#25328;Service<br />    Server:  鍏?#28729;?#28751;?#37828;疊ackGroud绋?#25652;?#38171;??#28266;Tomcat閲岄潰鐨凷erver鐨?#37922;?#28598;?#37828;?#37722;姩?#25328;鐩?#37722;?#37832;?#37716;?#32468;?#27996;?#28000;?#38171;?#29831;?#28641;?#38322;?#37722;?#37510;?#37711;?#38338;?#32475;?#37723;戒护銆??#28266;tomcat鐨勬?#22247;噯閰嶇疆鏂?#28000;?#38171;歴erver.xml閲岄潰锛?鎴戜滑鍙?#28000;湅?#22476;“<Server port="8005" shutdown="SHUTDOWN" debug="0">”杩?#38322;?#37928;?SHUTDOWN"灏?#37828;痵erver?#28266;鐩?#37722;?#37832;?#37716;?#32468;?#27996;?#28000;?#37928;勬椂鍊欐墍浣?#37922;?#37928;?#37723;戒护瀛?#38171;?br />    Service锛??#28266;tomcat閲岄潰锛?service鏄?#37816;?#28051;绫?#38338;?#26864;?#37928;勮?#21893;鏂规銆?nbsp; 閫?#29999;?#37812;戜滑?#32048;榛樿浣?#37922;tomcat鎻愪緵鐨?#38171;Tomcat-Standalone 妯?#23534;?#37928;剆ervice銆??#28266;杩欑鏂?#23534;?#28051;?#37928;剆ervice鏃?#32513;?#37812;戜滑鎻愪緵瑙?#37835;jsp?#25328;servlet鐨勬湇鍔?#38171;?鍚屾椂涔?#37819;愪?#28058;粰鎴戜滑瑙?#37835;?#38344;?#37804;?#37826;?#37832;?#37928;勬湇鍔?#37510;?br />    <br />    Connector: Tomcat閮?#37828;湪瀹?#37731;?#38322;岄潰澶勭悊闂?#26864;?#37928;?#38171;?鑰屽鍣?#37721;堝埌鍝?#38322;屽幓鍙栧緱杈撳叆淇?#37805;?#37723;紵<br /> Connector灏?#37828;?#28051;撳共杩欎釜鐨?#37510;?浠栦細?#22968;浠巗ocket浼?#38315;?#26473;?#37833;?#37928;勬暟鎹?#38171;?灏佽鎴怰equest, 浼?#38315;?#32513;?#28729;?#37731;?#37833;?#28598;勭悊銆?br />    閫?#29999;?#37812;戜滑?#32048;鐢埌涓?#32457;岰onnector,涓绉?#37721;http connectoer锛?鐢?#37833;?#28028;?#38315;抙ttp闇?#30512;鐨?#37510;?鍙?#28051;绉?#37721;AJP锛??#28266;鎴戜滑鏁?#37722;坅pache涓巘omcat宸?#28003;?#37928;勬椂鍊?#38171;?apache涓巘omcat涔?#38338;?#28751;?#37828;?#38315;?#26473;?#26473;欎釜鍗?#29825;?#37833;?#27996;掑姩鐨?#37510;?锛?#29831;村埌apache涓巘omcat鐨勬暣鍚堝伐浣?#38171;?閫?#29999;?#37812;戜滑鐨勭洰鐨?#37828;?#28051;?#27996;?#29825;apache 鑾?#37721;?#38344;?#37804;?#29863;勬簮锛?鑰?#29825;tomcat鏉?#29785;?#37835;愬姩鎬?#37928;刯sp鎴?#38000;卻ervlet銆?#38171;?br />    Container: 褰揾ttp connector?#22968;闇姹備紶閫?#32513;?#26916;剁骇鐨刢ontainer: Engin鐨勬椂鍊?#38171;?鎴戜滑鐨勮?#21977;嚎灏?#25652;旇绉诲姩?#22476;Container杩欎釜灞傞潰鏉?#27996;?#37510;?br />    ?#28266;Container杩欎釜灞?#38171;?鎴戜滑鍖呭惈浜?绉?#28729;?#37731;?#38171;?Engin, Host, Context.<br />    Engin: 鏀跺埌service浼?#38315;?#26473;?#37833;?#37928;?#38343;?#30512;锛?澶勭悊鍚?#38171;?灏嗙粨鏋?#26473;?#37733;?#32513;檚ervice( service 鏄?#38315;?#26473;?connector 杩欎釜濯?#28000;?#37833;拰Engin浜掑姩鐨?).<br />    Host: Engin鏀跺埌service浼?#38315;?#26473;?#37833;?#37928;?#38343;?#30512;鍚?#38171;屼笉?#32048;鑷繁澶勭悊锛?鑰?#37828;?#27996;?#32513;?#37722;?#38315;?#37928;Host鏉?#28598;勭悊銆?br /> Host?#28266;杩?#38322;屽氨鏄?#38095;氭嫙涓?#37832;?#37928;勬剰鎬?#38171;?閫?#29999;?#37812;戜滑閮?#37721;細浣?#37922;?#28051;?#37340;涓?#37832;?#38171;?#37827;?#8220;localhost”鏈?#37734;?#37832;?#37833;?#28598;勭悊銆?<br />    Context: Host鎺埌浜?#28000;嶩ost浼?#26473;?#37833;?#37928;?#38343;?#30512;鍚?#38171;?涔熶笉?#32048;鑷繁澶勭悊锛?鑰?#37828;?#27996;?#32513;?#37722;?#38315;?#37928;凜ontext鏉?#28598;勭悊銆?<br />    姣?#28641;?#38171;?<<a href="http://127.0.0.1:8080/foo/index.jsp">http://127.0.0.1:8080/foo/index.jsp</a>><br />          <<a href="http://127.0.1:8080/bar/index.jsp">http://127.0.1:8080/bar/index.jsp</a>><br />    鍓?#38000;?#27996;?#32513;檉oo杩欎釜Context鏉?#28598;勭悊锛?鍚庤?#27996;?#32513;檅ar杩欎釜Context鏉?#28598;勭悊銆?br />    寰?#37828;?#37828;?#37722;?#38171;?context鐨勬剰鎬?#37711;?#28729;?#28751;?#37828;?#28051;?#37340;web app鐨勬剰鎬?#37510;?br />    鎴戜滑閫?#29999;?#38318;戒細?#28266;server.xml閲岄潰鍋?#26473;?#37837;?#37928;勯?#23943;疆<br />    <Context path="/foo" docBase="D:/project/foo/web" /><br />    杩欎釜context瀹?#37731;?#38171;屽氨鏄?#37922;?#37833;?#39582;?#37812;戜滑璇?#39582;?#37928;勪?#23338;効鐨勫湴鏂?#37928;?#37510;?br />    <br />    Compenent: 鎺?#28051;?#37833;?#38171;?鎴戜滑缁?#32513;?#29825;?#29825;component鏄?#39582;?#28000;涔?#37922;?#37928;?#37510;?br />    鎴戜滑寰楀厛鐞?#29785;?#28051;涓嬪鍣拰缁?#28000;?#37928;?#37711;崇郴銆?br />    闇?#30512;琚?#28028;?#38315;掑埌浜嗗鍣?#38322;岄潰锛??#28266;鍚?#38315;?#37928;勬椂鍊?#38171;??#32048;浼?#38315;?#32513;欎笅涓?#37340;瀹?#37731;?#28598;勭悊銆?br />    鑰屽鍣?#38322;岄潰鍙?#37929;涜?#21615;潃鍚勭鍚勬牱鐨?#32513;?#28000;?#38171;?鎴戜滑鍙?#28000;?#37918;?#29785;?#28051;?#37819;愪緵鍚勭鍚勬牱鐨勫鍊?#37832;?#37716;?#37510;?br />    manager: 褰?#28051;?#37340;瀹?#37731;?#38322;岄潰瑁?#27996;唌anager缁?#28000;?#37722;?#38171;?#26473;欎釜瀹?#37731;?#28751;?#37824;?#37816;乻ession绠?#37918;嗕簡锛?浜嬪疄涓婂湪tomcat閲岄潰鐨剆ession绠?#37918;?#38171;?灏?#37828;?#38344;?#37928;勫湪context閲岄潰瑁?#37928;manager component.<br />    logger: 褰?#28051;?#37340;瀹?#37731;?#38322;岄潰瑁?#27996;唋ogger缁?#28000;?#37722;?#38171;?杩欎釜瀹?#37731;?#38322;屾墍鍙?#37922;?#37928;勪簨鎯?#38171;?灏?#29722;?#29831;?#32513;?#28000;?#29825;?#35120;?#28051;?#37833;?#37727;?#38171;?鎴戜滑閫?#29999;镐細?#28266;logs/ 杩欎釜?#27952;褰?#28051;嬬?#23341; catalina_log.time.txt 浠?#37721;?localhost.time.txt ?#25328;localhost_examples_log.time.txt銆?杩?#28751;?#37828;?#37733;?#28051;?#37812;戜滑鍒?#37714;?#28051;?#38171;歟ngin, host浠?#37721;奵ontext(examples)杩欎?#22793;釜瀹?#37731;?#28729;夎浜唋ogger缁?#28000;?#38171;?杩欎篃鏄?#27035;樿瀹夎锛?鍙?#37721;?#37707;?#37837;囬厤 锛?#38171;?br />    loader: loader杩欎釜缁?#28000;?#38315;?#29999;?#37721;細缁?#37812;戜滑鐨刢ontext瀹?#37731;?#28003;?#37922;?#38171;?loader鏄?#37922;?#37833;?#37722;姩context浠?#37721;婄鐞?#26473;欎釜context鐨刢lassloader鐢?#37928;?#37510;?br />     pipline: pipeline鏄?#26473;?#37837;蜂竴?#37340;涓滆锛?褰?#28051;?#37340;瀹?#37731;喅?#30078;浜?#29781;佹妸浠?#28051;婄骇浼?#38315;?#26473;?#37833;?#37928;?#38343;姹備氦缁?#28699;?#28729;?#37731;?#37928;勬椂鍊?#38171;?浠栧氨?#22968;杩欎釜闇姹傛斁杩?#28729;?#37731;?#37928;勭閬?pipeline)閲岄潰鍘?#37510;?鑰?#38343;姹傚偦鍛?#37723;?#23536;楀湪绠?#38316;?#38322;岄潰娴佸姩鐨勬椂鍊?#38171;?灏变細琚?#32480;?#38316;?#38322;岄潰鐨?#37722;勪釜闃闂?#37815;?#37812;?#28051;?#37833;?#37510;?姣?#28641;傜閬?#38322;岄潰鏀?#27996;?#28051;釜闃闂?#37510;?绗?#28051;?#37340;闃闂?#37721;?#37707;?#8220;access_allow_vavle”锛?涔?#28751;?#37828;?#29831;?#38343;?#30512;娴?#26473;?#37833;?#37928;勬椂鍊?#38171;屽?#20903;細鐪嬭?#27406;釜闇?#30512;鏄?#37725;釜IP杩?#37833;?#37928;?#38171;?濡?#37835;?#26473;欎釜IP宸?#32513;忓湪榛?#37722;?#37719;?#38322;岄潰浜?#38171;?sure, 鏉锛?绗?#27996;屼釜闃闂?#37721;?#37707;?#8220;defaul_access_valve”瀹冧細鍋?#28186;嬭鐨勬?#29025;锛?濡?#37835;滈?#26473;?#37928;?#29831;?#38171;孫K锛??#22968;闇姹備紶閫?#32513;?#35120;撳墠瀹?#37731;?#37928;?#28699;?#28729;?#37731;?#37510;?灏?#37828;?#38315;?#26473;?#26473;欑鏂?#23534;?#38171;?闇?#30512;灏卞湪鍚勪釜瀹?#37731;?#38322;岄潰浼?#38315;?#38171;?#23092;佸姩锛?鏈鍚庢姷杈剧洰鐨勫湴鐨勪簡銆?br />     valve: 灏?#37828;?#28051;婇潰?#22669;璇?#37928;?#38339;闂?#37727;?#37510;?br />    Tomcat閲岄潰澶?#22994;?#28751;?#37828;?#26473;欎箞浜?#28051;滆锛?鎴戜滑鍙?#28000;?#32480;鍗曞湴杩欎箞鐞?#29785;tomcat鐨勬鏋?#38171;屽畠鏄?#28051;绉嶈嚜涓?#38000;?#28051;?#38171;?瀹?#37731;?#38322;?#37721;?#37718;呭惈瀛?#28729;?#37731;?#37928;勮繖鏍蜂竴绉嶇粨鏋?#37510;?br /> 2. Tomcat鐨?#37722;姩娴佺<br />    杩欑瘒鏂?#32468;?#37828;?#29825;tomcat鎬?#28052;?#37722;姩鐨?#38171;?#37827;劧鎴戜滑澶?#28003;?#28051;?#27996;?#29785;?#27996;員OMCAT鐨勬鏋剁粨鏋勪簡锛?閭?#28052;?#37812;戜滑鍙?#28000;?#37832;?#37826;?#37922;熸?#24531;湴灏辩寽?#22476;tomcat鐨?#37722;姩锛??#32048;?#21403;鍚姩鐖?#28729;?#37731;?#38171;岀劧鍚?#38315;愪釜鍚姩閲岄潰鐨?#28699;?#28729;?#37731;?#37510;?鍚姩姣?#28051;?#37340;瀹?#37731;?#37928;勬椂鍊?#38171;?閮戒細鍚姩瀹?#37819;掑湪浠?#38892;?#28051;?#37928;?#32513;?#28000;?#37510;?褰撴墍鏈?#37928;?#32513;?#28000;?#37722;姩瀹屾瘯锛??#22669;鏈?#37928;?#28729;?#37731;?#37722;姩瀹屾瘯鐨勬椂鍊?#38171;?tomcat鏈?#38892;?#28052;?#28751;?#37722;姩瀹屾瘯浜?#37510;?br />    椤虹悊鎴?#32468;犲湴锛?鎴戜滑鍚?#37837;?#37721;?#28000;寽?#22476;锛?tomcat鐨?#37722;姩?#32048;鍒?#37812;?#28051;?#28598;?#38318;?#37714;?#38171;?绗?#28051;姝?#37828;?#29761;呴厤宸?#28003;?#37510;?绗?#27996;屾鏄?#37722;姩宸?#28003;?#37510;?<br />    瑁呴厤宸?#28003;?#28751;?#37828;?#28051;虹埗瀹?#37731;?#29761;?#28051;?#28699;?#28729;?#37731;?#38171;?涓?#37722;勪釜瀹?#37731;?#28729;?#37819;?#26473;涚粍浠?#37928;勫伐浣?#37510;?杩欎釜鍦?#37826;?#37812;戜滑?#32048;鐢埌digester妯?#23534;?#38171;?鑷?#27996;巇igester妯?#23534;?#28000;涔?#38171;?鏈?#28000;涔?#37922;?#38171;?鎬?#28052;堝伐浣?#37928;? 璇?#37721;?#38000;?<<a href="http://software.ccidnet.com/pub/article/c322_a31671_p2.html">http://software.ccidnet.com/pub/article/c322_a31671_p2.html</a>><br />    鍚姩宸?#28003;?#37828;湪瑁呴厤宸?#28003;?#28052;?#37722;?#38171;?涓鏃?#29761;呴厤鎴?#37716;?#27996;?#38171;?鎴戜滑灏?#37721;?#38343;瑕?#37904;?#37909;?#37832;涓婇潰鐨?#28051;鏍?#28725;肩嚎锛?鏁翠釜tomcat灏变細琚縺娲?#29863;?#37833;?#37510;?杩?#28751;卞姣?#37812;戜滑瑕?#23534;涓杈嗗凡缁忚?#21620;厤濂戒簡鐨勬杞?#37928;勬椂鍊欎竴鏍?#38171;?#37812;戜滑鍙?#29781;佹妸閽?#37718;?#37819;?#26473;?#38333;?#37718;?#28699;?#38171;?#28051;鎷?#38171;屾杞?#37928;?#23534;曟?#24225;氨?#32048;鍙戝姩璧?#37833;?#38171;岀?#40511;皟灏变細寮璧?#37833;?#38171;?瀹夊叏瑁呯疆灏变細鐢熸晥锛?濡傛涓鏉?#38171;屾杞?#37825;翠釜灏?#37721;戝姩璧?#37833;?#27996;?#37510;?#38171;?#26473;欎釜杩?#32459;?#32429;?#28729;炲拰TOMCAT鐨?#37722;姩杩?#32459;嬩笉璋嬭屽拰锛?璁?#37812;戜滑?#31497;寰椾笉鎬鐤?TOMCAT鐨勮璁?#38000;?#37828;湪GE鍋欽AVA寮鍙?#37928;?#38171;?#37510;?br /> 2.1 涓浜?#37832;夋剰鎬?#37928;?#37722;嶇锛?br />    Catalina<br />    Tomcat<br />    Bootstrap<br />    Engin<br />    Host<br />    Context<br />    浠栦滑鐨勬剰鎬?#23536;?#37832;夋剰鎬?#38171;?br />    Catalina: 杩?#32459;嬭桨鐐?#37832;?br />    Tomcat: 鐔婄尗杞?#37904;?#37832;?-- 杞?#37904;?#37832;?#37928;?#28051;绉?#38171;?#26473;?#29825;?#37812;?#37807;?#29863;蜂簡璁?#37733;戒汉寮?#28000;?#28051;?#29854;?#37928;勭?#23108;尗鎵?#37832;?#38171;?#37828;笉鏄嫳鏂?#37721;?#28000;?#37721;?#37707;歵omcat??? 锛?鍙?#29825;?#37812;?#37807;?#29863;蜂簡鍙?#28051;鍒?#39582;?#37723;?#38171;?娉?#28725;?鎵?#37832;?#28051;?#37928;勬鏂?#37832;?#37510;?#23049;?#38346;?瀹?#37832;?#28051;?#37928;勬鏂?#37832;?锛?br />    Bootstap: 寮曞<br />    Engin: 鍙戝姩鏈?br />    Host: 涓?#37832;?#38171;?#26864;嗗湡<br />    Context: 鍐呭锛??#27952;鏍?#38171;?涓?#28051;?#37826;?br />    <br />    ... ?#28266;璁?#28598;?#29825;?#28598;?#39582;?#37722;?#38171;?鐜?#28000;?#27996;虹?#35826;凡缁忕伃缁?#37510;?鍚?#37916;?#28000;?#37922;?#37911;?#37721;?#37916;?#27996;?#26473;欎簺鍗?#29831;?#38342;惰惤闆惰?#34249;湪涓鍧?#37510;?涓?#37340;鑷?#28000;?#28051;鸿鏄?#37928;?#28729;?#28028;欐妸杩欎簺涓滆?#36328;璇?#37713;?#37833;?#27996;?#38171;?<br />    ?#28266;鍦板浜?#37723;?#37928;?#23534;曞(bootstrap)涓?#38171;?涓鏋惰桨鐐?#37835;?catalina)鑵剧?#40511;璧?#38171;?杩滅湅鏄?#37908;婄尗杞?#37904;?#37832;?tomcat)锛?杩戠?#23341;繕鏄?#37908;婄尗杞?#37904;?#37832;?#38171;?鍑?#37706;熺潃浼樼鐨?#37721;戝姩鏈烘妧鏈?engin)锛?杩?#37835;剁?#23108;尗杞?#37904;?#37832;洪涓?#27996;嗘?#23677;浗鐨?#26864;嗗湡涓婄(host)锛?瀵?#37713;嗙洰鏍?context)鎶?#28051;?#27996;?#23011;?#28598;?#37903;?#37734;?#37928;勬牳寮?#28598;?#38171;?#23049;~ 鐜?#28000;?#37922;?#37911;?#28751;?#26473;欎?#22565;殧灞?#27996;~<br />  <br />    缁?#28051;婃墍杩?#38171;?杩?#37721;堜笉寰椾笉璁?#27996;鸿仈鎯冲埌GE鏄笉鏄?#28052;?#37721;?#28051;?#27996;?#37712;?#27996;嬭澶?#37928;?#37922;熶骇鍛紵<br />    鍙?#28725;圭甯?#37733;?#28051;?#28052;?#38171;?鍙?#28725;圭闇?#37833;?#28051;?#28052;?#38171;?鍜屽钩涓囧瞾锛?鑷?#37922;?#28051;囧瞾锛?br />    <br /> 2.2  鍘?#37721;?#28751;?#37828;?#38317;?#28052;?#37807;?#27996;?#37928;勭浉浼?#38171;?tomcat鐨?#37722;姩灏?#37828;?#28000;org.apache.catalina.startup.Bootstrap杩欎釜绫绘?#23943;劧鍚姩鐨?#38171;?br />    ?#28266;Bootstrap閲屽仛浜?#28051;?#28000;朵簨锛?br />    1. 鎸囧畾浜?绉?#32491;诲瀷classloader:<br />       commonLoader: common/classes銆乧ommon/lib銆乧ommon/endorsed<br />       catalinaLoader: server/classes銆乻erver/lib銆乧ommonLoader<br />       sharedLoader锛?nbsp; shared/classes銆乻hared/lib銆乧ommonLoader<br />    2. 寮曞Catalina鐨?#37722;姩銆?br />       鐢Reflection鎶鏈皟鐢org.apache.catalina.startup.Catalina鐨刾rocess鏂规硶锛?骞?#28028;?#38315;?#37721;傛暟杩囧幓銆?br />    <br /> 2.3 Catalina.java<br />    Catalina瀹?#37812;愪簡鍑犱釜閲?#29781;?#37928;?#28000;诲姟锛?br />    1. 浣?#37922;Digester鎶鏈?#29761;呴厤tomcat鍚勪釜瀹?#37731;?#28051;?#32513;?#28000;?#37510;?br />       1.1 瑁呴厤宸?#28003;?#37928;?#28051;?#29781;?#37712;呭鏄?#28729;夎?#21613;?#21226;釜澶?#28000;?#37510;?姣?#28641;server涓?#37832;?#28000;涔?#37837;?#37928;剆ervcie銆?Host?#32048;瀹圭澶氬?#25116;釜context銆?Context閮戒細浣?#37922;埌鍝?#27996;涚粍浠剁瓑绛?#37510;?<br />       1.2 鍚屾椂鍛?#38171;??#28266;瑁呴厤宸?#28003;?#26473;欎竴姝?#38171;?杩?#28729;?#37812;愪簡mbeans鐨勯?#23943;疆宸?#28003;?#37510;??#28266;杩?#38322;?#38171;?#37812;戠畝鍗曞湴浣嗕笉鍗?#37714;嗙簿纭?#37734;?#37819;?#26473;?#28051;涓媘bean鏄?#28000;涔?#38171;屽共浠涔?#37922;?#37928;?#37510;?br />           鎴戜滑鑷繁鐢?#37812;?#37928;?#28725;硅薄锛?鑷繁绠?#37918;?#38171;?澶?#32513;忓湴涔?#38171;?浣?#37828;?#28641;?#37835;?#37812;戜滑鍒涘缓浜嗗?#30789;薄浜?#38171;?鎯?#29825;?#37714;?#27996;?#37833;?#32480;?#38171;?鎬?#28052;?#37716;?#37723;紵 鎴?#37807;?#38007;冲皯寰楀憡璇?#37714;?#27996;?#37812;戜滑閮?#37832;?#28000;涔?#38171;?浠?#37721;?#38315;?#26473;?#28000;涔?#37826;规硶鍙?#28000;?#37813;惧埌  鍚?#38171;?JMX鎶鏈?#32513;?#37812;戜滑鎻愪緵浜?#28051;绉嶆墜娈?#37510;?JMX閲岄潰涓?#29781;?#37832;?绉?#28051;滆銆侻bean, agent, connector.<br />        Mbean锛?鐢?#37833;?#37828;犲?#21228;?#25116;滑鐨?#28725;硅薄銆備篃璁竚bean灏?#37828;?#37812;戜滑鍒涘缓鐨?#28725;硅薄锛?涔?#29825;镐笉鏄?#38171;?浣?#37832;?#27996;嗗畠锛?灏?#37721;?#28000;?#23534;?#37922;埌鎴戜滑鐨?#28725;硅薄浜?#37510;?br />        Agent:  閫?#26473;囧畠锛?灏?#37721;?#28000;?#37813;惧埌mbean浜?#37510;?br />        Connector: 杩?#37818;Agent鐨勬柟寮?#37510;?鍙?#28000;?#37828;痟ttp鐨?#38171;?涔?#37721;?#28000;?#37828;rmi鐨?#38171;?#26473;?#37721;?#28000;?#37929;?#37818;?#38315;?#26473;socket銆?br />       鍙?#37922;熷湪tomcat 瑁呴厤杩?#32459;?#28051;?#37928;勪簨鎯?  GlobalResourcesLifecycleListener 绫?#37928;?#37714;?#28654;嬪?#26662;細琚?#29785;?#37721;?#38171;?br />          protected static Registry registry = MBeanUtils.createRegistry();  ?#32048;杩?#29723;?br />          MBeanUtils.createRegistry()  ?#32048;渚?#37817;?org/apache/catalina/mbeans/mbeans-descriptors.xml杩欎釜閰嶇疆鏂?#28000;?#37714;涘缓 mbeans. Ok, 澶栫?#23677;氨鏈?#27996;?#37833;?#38315;?#23536;勮闂tomcat涓?#37928;?#37722;勪釜缁?#28000;朵簡銆?#38171;?#37832;?#37904;瑰儚鍚?#38338;?#37710;?#38171;?br />    2. 涓簍op level 鐨剆erver 鍋?#37714;?#28654;嬪?#26663;伐浣?#37510;?瀹?#38340;?#28051;?#28751;?#37828;?#37707;?#38315;?#29999;镐細閰嶇疆缁檚ervice鐨?#28051;?#37833;connector.(http, ajp)<br />    3. 浠巗erver杩欎釜瀹?#37731;?#23534;濮?#37722;姩锛?鐐?#37909;?#37825;翠釜tomcat.<br />    4. 涓簊erver鍋?#28051;?#37340;hook绋?#25652;?#38171;?妫娴?#35120;server shutdown鐨勬椂鍊?#38171;?鍏?#38338;tomcat鐨?#37722;勪釜瀹?#37731;?#37922;?#37510;?br />    5. 鐩?#37722;?005绔?#37721;?#38171;?濡?#37835;?#37721;戦?SHUTDOWN"锛?#27035;樿鍩规涓?#28699;?#32471;?#28051;?#38171;?#26473;?#37833;?#38171;?鍏?#38338;?005serverSocket銆?br /> 2.4 鍚姩鍚勪釜瀹?#37731;?br />    1. Server<br />       瑙?#37721;慡erver瀹?#37731;?#37722;姩鍓?before_start)锛?鍚姩涓?start)锛?鍚姩鍚?after_start)3?#37340;浜?#28000;?#38171;?骞?#26473;?#29723;岀浉搴?#37928;勪簨浠?#28598;勭?#21975;櫒銆?br />       鍚姩Server鐨?#28699;?#28729;?#37731;?#38171;歋ervcie. <br />    2. Service<br />       鍚姩Service鐨?#28699;?#28729;?#37731;?#38171;欵ngin<br />       鍚姩Connector<br />    3. Engin<br />       ?#22476;浜Engin杩欎釜灞傛锛?#28000;?#37721;?#28000;?#28051;嬬骇鍒?#37928;?#28729;?#37731;?#38171;?Tomcat灏?#28003;?#37922;?#27996;?#23011;旇緝涓?#22183;鐨?#37722;姩鏂?#23534;?#27996;?#37510;?br />       棣栧厛锛?nbsp; 杩?#29723;?#37722;勪釜瀹?#37731;?#38007;繁鐗规湁涓浜?#28000;诲姟<br />       闅?#37722;?#38171;?nbsp; 瑙?#37721;?#37722;姩鍓?#27996;?#28000;?br />       绔?#37719;?#38171;?nbsp; 璁?#32515;?#37837;?#32475;?#38171;屽氨琛?#32448;?#29831;?#28729;?#37731;?#23480;?#32513;?#37722;姩<br />       鎺潃锛?nbsp; 鍚姩瀹?#37731;?#28051;?#37928;?#37722;勪釜缁?#28000;?#38171;?loader, logger, manager绛?#32475;?br />       鍐?#37818;潃锛?#37722;姩mapping缁?#28000;?#37510;?#38171;?#23049;?锛?br />       ?#25571;璺熺潃锛?#37722;姩瀛?#28729;?#37731;?#37510;?br />       鎺?#28051;?#37833;?#38171;?#37722;姩璇?#28729;?#37731;?#37928;勭閬?pipline)<br />       ?#21159;鍚?#38171;?nbsp; 瑙?#37721;?#37722;姩涓?#27996;?#28000;?br />       鏈鍚?#38171;?nbsp; 瑙?#37721;?#37722;姩鍚?#27996;?#28000;?#37510;?br />  <br />       Engin澶嚧?#32048;杩欎?#22557;仛锛?Host澶嚧涔熶細杩欎?#22557;仛锛?Context澶嚧杩?#37828;細杩欎?#22557;仛銆?閭?#28052;?#23536;?#37828;剧劧鍦?#38171;?鎴戜滑闇瑕佸湪杩?#38322;?#28003;?#37922;埌浠?#37934;?#28598;?#37922;?#37928;勬妧鏈?#37510;?tomcat?#28266;澶勭悊杩欎釜闂?#26864;?#37928;勬椂鍊?#38171;?婕備寒鍦?#28003;?#37922;?#27996;嗘娊?#34180;绫?#37833;?#28598;勭悊銆?ContainerBase. 鏈鍚?#28003;?#23536;?#26473;?#38318;?#37714;嗗畬鎴?#28598;?#37833;?#37716;熻兘鐨?#28000;?#37934;?#37828;?#23536;楀共鍑鍒?#38016;?#38171;?骞?#32513;?#37910;藉揩锛?瀹炲湪鏄护浜?#29785;夊?#26944;徆涓?#29785;傛锛?缁?#32513;嗗鏉?#38171;?鐩?#29785;夊?#20633;韩浣崇弽锛?鍙?#27996;洪娇棰婄暀棣?#38171;??#26240;鎭?#23536;杩?#37727;?#38171;?br />       <br />       Engin鐨勮鍙?#37722;姩鍓?#27996;?#28000;?#38322;?#38171;??#32048;?#32314;娲荤?#25117;畾?#28266;Engin涓?#37928;勫敮涓涓?#37340;Listener锛欵nginConfig銆?br />       杩欎釜EnginConfig绫诲熀鏈?#28051;婃病鏈夊仛浠涔?#27996;?#37807;?#38171;?灏?#37828;妸EnginConfig鐨勮皟璇曠骇鍒?#29825;?#32515;?#28051;哄拰Engin?#27977;褰?#37510;?鍙?#28598;栧氨鏄?#26440;?#37713;?#37713;?#29723;?#37826;?#37832;?#38171;?琛?#32448;篍ngin宸?#32513;?#38320;嶇疆瀹屾瘯锛?骞舵病鏈夊仛浠涔?#28729;?#29840;?#37804;?#37928;勫伐浣?#37510;?br />       娉?: mapping缁?#28000;?#37928;?#37922;?#28598;?#37828;?#38171;?褰?#28051;?#37340;闇?#30512;灏?#29781;?#28000;庣埗瀹?#37731;?#28028;?#38315;掑埌瀛?#28729;?#37731;?#37928;勬椂鍊?#38171;?鑰岀埗瀹?#37731;?#37721;?#37832;?#28598;氫釜瀛?#28729;?#37731;?#37928;?#29831;?#38171;?閭?#28052;?#25652;旇閫夋嫨鍝釜瀛?#28729;?#37731;?#37833;?#28598;勭悊闇?#30512;鍛紵 杩欎釜鐢眒apping 缁?#28000;?#37833;畾澶?#37510;?br />     <br />    4. Host<br />        鍚孍ngin涓鏍?#38171;?涔?#37828;皟鐢ContainerBase閲岄潰鐨剆tart()鏂规硶锛??#31497;杩囦?#23338;墠鍋?#27996;嗕簺鑷釜鍎?#37928;?#28000;诲姟,灏?#37828;?#23536;Host杩欎釜瀹?#37731;?#37928;勯?#38316;?#38171;坧ipline锛?#38322;岄潰锛?瀹夎浜?#28051;?#37340;鍙?#37707;?br />  “org.apache.catalina.valves.ErrorReportValve”鐨?#38339;闂?#37510;?br />        杩欎釜闃闂?#37928;?#37922;?#28598;?#37828;?#26473;?#37837;?#37928;?#38171;?nbsp; 闇姹傚湪琚獷ngin浼?#38315;?#32513;Host鍚?#38171;??#32048;缁?#32513;?#28028;?#38315;?#32513;Context鍋?#37711;蜂綋鐨?#28598;勭悊銆?杩?#38322;?#38343;?#30512;鍏?#28729;?#28751;?#37828;?#28003;?#28051;?#37721;傛暟浼?#38315;?#37928;凴equest, Response銆??#22669;浠湪context?#22968;闇?#30512;澶勭?#21975;畬鍚?#38171;?閫?#29999;镐細?#25980;?#23017;response銆?鑰?#26473;欎釜org.apache.catalina.valves.ErrorReportValve鐨?#28003;?#37922;?#28751;?#37828;?#22955;瀵焤esponse鏄惁鍖呭惈?#25930;璇?#38171;?濡?#37835;?#37832;夊?#21342;?#27697;浉搴?#37928;?#28598;勭悊銆?br />    5. Context<br />        ?#22476;浜?#26473;?#38322;?#38171;?灏?#32513;?#27996;庤疆?#22476;浜唗omcat鍚姩涓?#37930;熸鐨?#38322;?#28598;?#37812;?#38171;?#37722;姩Context浜?#37510;?br />  StandardContext.start() 杩欎釜鍚姩Context瀹?#37731;?#37928;勬?#35268;硶琚StandardHost?#30367;鐢?<br />  5.1 webappResources 璇context?#22669;鎸囧悜鐨?#37711;蜂綋?#27952;褰?br />  5.2 瀹夎defaultContex, DefaultContext 灏?#37828;?#27035;樿Context銆?濡?#37835;?#37812;戜滑?#28266;涓?#37340;Host涓嬮潰瀹夎浜咲efaultContext锛岃?#28051;defaultContext閲岄潰鍙?#28729;夎浜?#28051;?#37340;?#26271;鎹?#25652;?#26473;?#37818;?#23033;?#29863;勬簮鐨?#29831;?#37510;?閭?#28052;?#37711;?#28000;栨墍鏈?#37928;勫湪璇Host涓?#37928;凜ontext, 閮?#37721;?#28000;?#37929;?#37818;?#28003;?#37922;?#26473;欎釜?#26271;鎹?#25652;?#26473;?#37818;?#23033;?#38171;?鑰屼笉鐢?#37837;?#28598;栧仛閰嶇疆浜?#37510;?br />   5.3 鎸囧畾Loader. 閫?#29999;?#37922;?#27035;樿鐨刼rg.apache.catalina.loader.WebappLoader杩欎釜绫?#37510;?nbsp;  Loader灏?#37828;?#37922;?#37833;?#37816;囧畾杩欎釜context?#32048;鐢埌鍝?#27996;涚?#35826;晩锛?鍝?#27996;沯ar鍖呭晩杩欎簺浠涔?#37928;?#37510;?br />  5.4 鎸囧畾 Manager. 閫?#29999;?#28003;?#37922;?#27035;樿鐨刼rg.apache.catalina.session. StandardManager 銆?Manager鏄?#37922;?#37833;?#32480;?#37918;唖ession鐨?#37510;?br />      鍏?#28729;session鐨勭鐞嗕篃寰?#28610;?#28729;?#37916;?#37510;?浠?#28051;绉嶇畝鍗?#37928;剆ession绠?#37918;?#28051;?#28186;?#37510;?褰?#38343;姹備紶閫?#26473;?#37833;?#37928;勬椂鍊?#38171;??#28266;Request瀵硅薄閲岄潰鏈?#28051;?#37340;sessionId 灞?#37804;?#37510;?OK锛?寰楀埌杩欎釜sessionId鍚?#38171;?鎴戜滑灏?#37721;?#28000;妸瀹?#28003;?#28051;簃ap鐨刱ey锛岃寁alue鎴戜滑鍙?#28000;?#37824;?#32515;?#28051;?#37340;HashMap. HashMap閲?#26440;瑰効锛?鍐嶆斁鎴戜滑鎯?#37824;?#37928;?#28051;滆銆?br />  5.5 postWorkDirectory (). Tomcat涓嬮潰鏈?#28051;?#37340;work?#27952;褰?#37510;?鎴戜滑?#22968;涓存椂鏂?#28000;?#38318;?#37813;斿湪閭?#37710;?#37720;?#37510;?杩欎釜姝?#26976;?#28751;?#37828;湪閭?#38322;?#37714;涘缓涓?#37340;?#27952;褰?#37510;?涓鑸?#29831;?#37833;細?#28266;%CATALINA_HOME%/work/Standalone\localhost\ 杩欎釜鍦?#37826;?#37922;?#37812;?#28051;?#37340;?#27952;褰?#37510;?br /> 5.6  Binding thread銆傚埌浜?#26473;?#38322;?#38171;?灏?#25652;旇鍙?#37922;?class Loader 浜掓崲浜?#37510;?涔嬪墠鏄湅寰?#29785;tomcat涓嬮潰?#22669;鏈?#37928;刢lass?#25328;lib. 鎺?#28051;?#37833;?#38343;瑕佺湅寰?#29785;?#35120;撳墠context涓?#37928;刢lass銆??#22669;浠?#29781;?#29825;?#32515;甤ontextClassLoader, 鍚屾椂杩樿?#20345;妸鏃?#37928;凜lassLoader璁?#35120;?#28051;?#37833;?#38171;屽洜涓?#28000;?#37722;?#26473;樿鐢?#37928;?#37510;?br /> 5.7  鍚姩 Loader. 鎸囧畾杩欎釜Context鍏蜂綋瑕?#28003;?#37922;?#37725;?#27996;沜lasses锛?鐢埌鍝?#27996;沯ar鏂?#28000;?#37510;?濡?#37835;reloadable璁?#32515;?#37812;愪簡true, 灏变細鍚姩涓?#37340;?#22158;绋?#37833;?#37929;戣?#21755;lasses鐨?#37721;樺寲锛?濡?#37835;?#37832;?#37721;樺?#26663;氨閲?#37826;?#37722;姩Context銆?br /> 5.8  鍚姩logger<br /> 5.9  瑙?#37721;?#28729;夎?#21613;湪瀹?#38892;?#28051;?#37928;?#28051;?#37340;鐩?#37722;?#37731;?#37510;?br />  lifecycle.fireLifecycleEvent(START_EVENT, null); <br />  浣?#28051;虹洃鍚?#37731;?#28052;?#28051;锛孋ontextConfig?#32048;琚?#37722;姩. ContextConfig灏?#37828;?#37922;?#37833;?#38320;嶇疆web.xml鐨?#37510;?姣?#28641;?#26473;欎釜Context鏈?#28598;氬皯Servlet锛?鍙?#37832;?#28598;氬皯Filter锛?灏?#37828;湪杩?#38322;?#32513;Context瑁?#28051;?#37720;?#37928;?#37510;?br />  5.9.1 defaultConfig. 姣忎釜context閮?#23536;?#38320;嶇疆 tomcat/conf/web.xml 杩欎釜鏂?#28000;?#37510;?br />  5.9.2 applicationConfig 閰嶇疆鑷繁鐨?WEB-INF/web.xml 鏂?#28000;?br /> 5.9.3 validateSecurityRoles 鏉?#38340;?#26976;?#29831;?#37510;?閫?#29999;?#37812;戜滑?#28266;璁?#38338;?admin 鎴?#38000;?manager鐨勬椂鍊?#38171;?#38343;瑕?#37922;?#37812;?#29781;?#28052;?#37828;admin鐨勮涔?#37828;痬anager鐨?#38171;?鎵嶈兘璁?#38338;?#37510;?鑰?#28051;?#37812;戜滑杩?#37721;?#28000;?#38340;?#37714;堕偅浜?#29863;勬簮鍙?#28000;?#29825;?#38338;?#38171;?鑰屽摢浜涗笉?#20824;銆?閮?#37828;湪杩?#38322;屽疄鐜?#37928;?#37510;?br /> 5.9.4 tldScan: 鎵?#37819;?#28051;涓?#38171;?闇瑕?#37922;埌鍝?#27996;?#37837;?#32475;?tag lab)<br /> 5.10 鍚姩 manager<br /> 5.11 postWelcomeFiles() 鎴戜滑閫?#29999;镐細鐢埌鐨??#37340;鍚姩鏂?#28000;?#37928;?#37722;嶇锛?br /> index.html銆乮ndex.htm銆乮ndex.jsp 灏?#29722;?#27035;樿鍦?#32513;戝湪浜?#26473;欎釜context涓?br />  5.12 listenerStart 閰嶇疆listener<br />  5.13 filterStart 閰嶇疆 filter<br />  5.14 鍚姩甯?#37832;?lt;load-on-startup>1</load-on-startup>鐨凷ervlet.<br />   椤?#25652;?#37828;?#28000;庡?#24531;埌澶?#38171;?1,2,3… 鏈鍚?#37828;?<br />   榛樿鎯呭喌涓?#38171;?鑷冲?#25116;細鍚姩濡?#28051;??#37340;鐨凷ervlet: <br />   org.apache.catalina.servlets.DefaultServlet   <br />       澶勭悊闈?#37804;?#29863;勬簮鐨凷ervlet. 浠涔堝浘鐗囧晩锛?html鍟?#38171;?css鍟?#38171;?js鍟?#38318;?#37813;?#28000;?br />   org.apache.catalina.servlets.InvokerServlet<br />       澶勭?#21976;病鏈夊仛Servlet Mapping鐨勯偅浜汼ervlet.<br />   org.apache.jasper.servlet.JspServlet <br />       澶勭悊JSP鏂?#28000;?#37928;?<br />        5.15  鏍?#29831;哻ontext宸?#32513;?#37722;姩瀹屾瘯銆?br />  璧?#27996;?#28598;氬?#25116;釜姝?#26976;?#37727;?#38171;?Context鎬荤畻鏄?#37722;姩瀹屾瘯?#26598;銆?br />     OK! 璧板埌浜?#26473;?#38322;?#38171;?姣忎釜瀹?#37731;?#28000;?#37721;?#32513;?#28000;?#38318;?#37722;姩瀹屾瘯銆?Tomcat缁?#27996;庝笉杈?#26440;?#37716;冲湴涓?#27996;烘?#25118;湇鍔?#27996;?#38171;?br /> 3. 鍙?#38000;?#37826;囩锛?br />     <<a href="http://jakarta.apache.org/tomcat/">http://jakarta.apache.org/tomcat/</a>><br />     <<a href="http://www.onjava.com/pub/a/onjava/2003/05/14/java_webserver.html">http://www.onjava.com/pub/a/onjava/2003/05/14/java_webserver.html</a>><br />     <br /> 4. 鍚?#29825;?br />     杩欑瘒鏂?#32468;?#37828;?#29825;?#29785;tomcat鍚姩妗?#37835;?#37928;?#38171;?#26473;?#37832;夌瘒鏂?#32468;?#37828;?#29825;?#29785;TOMCAT閲岄潰鐨勬秷鎭?#28598;勭悊娴佺鐨?#32513;嗚妭鐨?#37510;?鏂?#32468;?#37712;呭?#29808;凡缁?#37712;?#28610;戒簡锛?鐜板湪姝湪鏁?#37918;?#38339;?#23048;?#37510;??#27977;淇?#23536;堝揩灏?#37721;?#28000;?#37707;?#37713;?#37833;?#38171;?澶?#28729;?#37711;?#37722;岀?#26050;鍏?#37722;?#26473;?#23005;?#37510;?br />     杩欑瘒鏂?#32468;?#37828;嫭鑷?#37714;?#37835;怲OMCAT婧愮爜?#22669;鍐?#37928;?#38171;??#22669;浠?#28051;?#30078;鏈夊湴鏂?#37828;?#29999;?#37832;変釜浜?#28051;?#29785;傝壊褰?#38171;?闅?#37711;嶄細鏈?#37911;囬潰涔?#28598;?#37510;傝嫢鏈変笉褰?#28052;?#28598;勬暚璇?#37813;?#29831;勬?#22248;暀锛?#26473;?#37837;蜂笉浠?#37721;?#28000;?#28003;?#37714;?#23534;濮?#37934;旂?#31145;OMCAT鐨?#37711;勫紵?#28369;灏戣蛋寮矾锛?鎴戜篃鍙?#28000;?#28699;埌涓滆銆?br />     email: <a href="mailto:sojan_java@yahoo.com.cn">sojan_java@yahoo.com.cn</a></p> <p>5. <a href="http://www.csdn.net/develop/article/28/28075.shtm">tomcat婧愮爜鍒?#37835;?娑?#37805;?#28598;勭悊)</a></p> </span></td> </tr> </tbody> </table> <img src ="http://www.67529968.com/lingy/aggbug/292715.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2009-08-26 20:49 <a href="http://www.67529968.com/lingy/archive/2009/08/26/292715.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>鐢Digester绠鍖朮ML鏂囨澶勭悊http://www.67529968.com/lingy/archive/2009/08/26/292713.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Wed, 26 Aug 2009 12:27:00 GMThttp://www.67529968.com/lingy/archive/2009/08/26/292713.html 

    Digester妗?#37835;?#28766;炰簬Jakarta Commons锛屽畠浠?#29785;?#37714;欏拰妯?#23534;?#28051;哄?#34425;澶勭悊XML鏂囨銆?#28051;嶴AX?#25328;DOM涔?#32491;?#37928;勬?#22247;噯API?#27977;姣?#38171;孌igester?#31497;娑?#37721;?#28598;?#28598;?#37928;?#32513;嗚妭闂?#26864;?#38171;岄潪甯?#38315;?#37722;?#27996;庡XML鏂囨杩?#29723;岀畝鍗?#37928;?#28598;勭悊銆?

    ?#28266;Java?#25328;XML寮鍙戜腑锛?#28051;?#37340;甯歌鐨?#28000;诲姟鏄妸XML鏂囨?#27974;?#23858;鎴?#28725;?#25652;?#37928;凧ava Bean瀵硅薄鐨?#28766;傛?#31912;鏋?#37510;備汉?#28369;缁?#29999;?#37922;?#37837;囧噯鐨凷AX?#25328;DOM API鏉?#28729;?#37812;?#26473;欎釜浠诲姟銆傝?#30028;劧杩欎袱绉API閮?#23536;?#23534;?#28598;?#37724;岀伒娲?#38171;?#28003;嗗浜庢?#24874;?#28058;畝鍗?#37928;?#28000;诲姟鏉?#29831;?#38171;屽?#20903;滑鏄?#23536;楁搷浣?#28766;傛澶?#28003;?#38171;屼篃灏?#37828;?#29831;?#38171;屾秹鍙?#27996;?#28598;?#28598;?#37928;?#32513;嗚妭闂?#26864;?#37510;侸akarta Digester妗?#37835;惰兘澶?#23536;?#28610;?#37734;版弧瓒?#26473;?#32491;诲満鍚?#37928;?#38343;瑕?#37510;?

    Digester妗?#37835;剁畝浠?

    Jakarta鐨凞igester妗?#37835;?#28000;嶴truts妗?#37835;?#37721;?#28766;曡?#37833;?#38171;屽師?#21403;琚?#37922;?#37833;?#28598;勭悊struts-config.xml閰嶇疆鏂?#28000;?#38171;?#28003;嗗?#22557;揩浜轰滑璁?#29831;嗗埌瀹?#37832;夌潃鏇?#39582;挎硾鐨?#37922;?#38315;?#38171;屾妸瀹冭浆?#21446;浜咼akarta Commons椤圭洰銆侸akarta Commons鐨勭洰鏍?#37828;?#37819;愪緵涓?#37340;“鍙?#38322;?#37922;Java缁?#28000;?#37928;勪粨搴?#8221;銆侱igester鏈鏂?#37928;勭増鏈?#37828;?.3锛屼簬2002骞?鏈?3鏃?#37721;?#29999;?#37510;?

    Digester妗?#37835;?#37711;?#29825;?#23534;鍙戣?#37816;囧畾涓缁勫姩浣?#38171;屽綋瑙?#37835;?#37731;湪XML鏂囨涓?#37721;?#37916;?#37836;愪?#28058;?#29808;畾鐨勭畝鍗曟寮忔椂?#23017;浣?#29722;?#37813;?#29723;?#37510;侱igester妗?#37835;?#29999;?#37832;?0?#37340;棰勫畾涔?#37928;勮鍒?#38171;圧ule锛?#38171;屾鐩?#27996;唘nmarshalling XML锛?#28186;?#28641;?#37714;涘缓Bean鎴?#29825;?#32515;瓸ean灞?#37804;?#38171;?#37928;?#28598;?#28598;氭暟闇?#30512;锛?marshalling鐨勫?#29112;剰鏄?#37816;?#8220;?#21412;鍒?#37825;撮綈锛岀紪缁?#37714;楄溅”锛宮arshalling鏄湪鍐?#28699;?#28051;?#28051;Java瀵硅薄鐢?#37812;XML鎻?#26473;?#37826;囨鐨勮繃绋?#38171;岃寀nmarshalling鏄?#37816;囨妸XML褰?#23534;?#37928;勬弿杩拌浆?#23858;?#22476;鍙?#37922;Java浠?#37934;佹搷浣?#37928;?#28725;硅薄鐨勮繃绋?#38171;?#37812;戜滑绉?#28052;?#28051;?#8220;鍙嶉厤鍒?#8221;锛?#38171;?#28003;嗗繀瑕佹椂鐢?#37812;?#37721;?#28000;畾涔夊?#23677;疄鐜拌嚜?#32321;鐨勮鍒?#37510;?

    ?#28266;鏈?#37826;?#37928;勪緥瀛?#28051;?#38171;?#37812;戜滑灏?#37721;嶉厤鍒?#28051;嬮潰杩欎釜XML鏂囨锛?

    <?xml version="1.0"?>
                <catalog library="somewhere">
                <book>
                <author>Author 1</author>
                <title>Title 1</title>
                </book>
                <book>
                <author>Author 2</author>
                <title>His One Book</title>
                </book>
                <magazine>
                <name>Mag Title 1</name>
                <article page="5">
                <headline>Some Headline</headline>
                </article>
                <article page="9">
                <headline>Another Headline</headline>
                </article>
                </magazine>
                <book>
                <author>Author 2</author>
                <title>His Other Book</title>
                </book>
                <magazine>
                <name>Mag Title 2</name>
                <article page="17">
                <headline>Second Headline</headline>
                </article>
                </magazine>
                </catalog>

    涓嬮潰鏄疊ean鐨?#28000;?#37934;?#37510;?#23049;剰浣?#37922;Digester妗?#37835;舵椂锛孊ean绫诲繀椤诲畾涔?#37812;public銆?

    import java.util.Vector;
                public class Catalog {
                private Vector books;
                private Vector magazines;
                public Catalog() {
                books = new Vector();
                magazines = new Vector();
                }
                public void addBook( Book rhs ) {
                books.addElement( rhs );
                }
                public void addMagazine( Magazine rhs ) {
                magazines.addElement( rhs );
                }
                public String toString() {
                String newline = System.getProperty( "line.separator" );
                StringBuffer buf = new StringBuffer();
                buf.append( "--- Books ---" ).append( newline );
                for( int i=0; i<books.size(); i++ ){
                buf.append( books.elementAt(i) ).append( newline );
                }
                buf.append( "--- Magazines ---" ).append( newline );
                for( int i=0; i<magazines.size(); i++ ){
                buf.append( magazines.elementAt(i) ).append( newline );
                }
                return buf.toString();
                }
                }
                //===================================================
                public class Book {
                private String author;
                private String title;
                public Book() {}
                public void setAuthor( String rhs ) { author = rhs; }
                public void setTitle(  String rhs ) { title  = rhs; }
                public String toString() {
                return "Book: Author='" + author + "' Title='" + title + "'";
                }
                }
                //===================================================
                import java.util.Vector;
                public class Magazine {
                private String name;
                private Vector articles;
                public Magazine() {
                articles = new Vector();
                }
                public void setName( String rhs ) { name = rhs; }
                public void addArticle( Article a ) {
                articles.addElement( a );
                }
                public String toString() {
                StringBuffer buf = new StringBuffer( "Magazine: Name='" + name + "' ");
                for( int i=0; i<articles.size(); i++ ){
                buf.append( articles.elementAt(i).toString() );
                }
                return buf.toString();
                }
                }
                //===================================================
                public class Article {
                private String headline;
                private String page;
                public Article() {}
                public void setHeadline( String rhs ) { headline = rhs; }
                public void setPage(     String rhs ) { page     = rhs; }
                public String toString() {
                return "Article: Headline='" + headline + "' on page='" + page + "' ";
                }
                }

    1 2 涓?#28051;椤?gt;>

    Digester妗?#37835;?#28000;?#22959;?#23534;?#38171;Pattern锛夊拰瑙?#37714;?#38171;圧ule锛?#28051;哄?#34425;澶勭悊杈撳叆鐨刋ML銆傛寮忓繀椤?#28051;嶺ML鍏冪?#29362;尮?#21412;锛屽?#21614;嫭鍏?#37722;?#28699;楀?#23677;湪鏂囨鏍?#37712;?#37928;?#28003;嶇疆銆?#37819;?#26473;?#37718;?#38320;嶆寮?#37928;?#29831;硶绫?#28028;?#27996;嶺Path鍖?#38320;嶆寮?#38171;?#28186;?#28641;?#38171;歝atalog妯?#23534;?#37718;归厤椤?#28766;?#37928;?ccid_code><catalog>鍏冪礌锛宑atalog/book妯?#23534;?#37718;归厤鐩?#37818;?#23443;屽?#26944;湪<catalog>鍏冪礌鍐?#37928;?lt;book>鍏冪礌锛?#28003;嗕笉鍖归厤鏂囨鍐呭叾浠?#28003;嶇疆鐨?lt;book>鍏冪礌锛?/ccid_code>銆?

    ?#22669;鏈?#37928;勬寮?#38318;藉繀椤?#37816;囧畾鍏?#28729;屾暣鍚嶇鈥?#37413;?#28000;?#37837;?#37711;冪礌寮濮?#37928;?#28729;屾暣?#30718;寰?#37510;傚敮涓鐨勪緥澶?#37828;?#37718;呭惈閫氶厤绗?#38171;?#8220;*”锛?#37928;勬寮?#38171;?#28186;?#28641;?/name妯?#23534;?#37718;归厤XML鏂囨鍐?#28000;?#28003;?#28003;嶇疆鐨?ccid_code><name>鍏冪礌銆?#28003;?#37828;?#37837;?#37711;冪?#29361;笉蹇?#37911;?#37714;?#37816;囧嚭锛屽洜涓烘墍鏈?#37928;勮矾寰?#38318;?#37828;?#28000;?#37837;?#37711;冪礌寮濮?#37928;?#32513;?#28725;硅矾寰?#37510;?

    褰揇igester鍙?#37916;?#28051;?#37340;鎸囧畾鐨勬寮?#38171;屽畠灏?#37813;?#29723;?#37711;宠仈鐨?#28000;诲姟銆?#37922;?#23005;?#37721;?#29785;?#38171;孌igester妗?#37835;?#37828;剧劧涓嶴AX瑙?#37835;?#37731;?#37832;夌潃?#30225;鍒?#37928;?#37711;崇郴锛?#28729;?#38340;?#28051;?#38171;孌igester绫诲疄鐜?#27996;org.xml.sax.ContentHandler锛屽苟缁存姢?#28483;瑙?#37835;?#37837;?#38171;?#37510;傛墍鏈夊湪Digester涓?#28003;?#37922;?#37928;勮鍒?#36423;?#26916;?#37813;?#28766;org.apache.commons.digester.Rule锛?#37722;庤?#37832;?#38892;?#37819;愪緵浜?#28051;浜涚被浼?#27996;嶴AX鐨凜ontentHandler鍥炶皟鍑芥暟鐨勬?#35268;硶銆備緥濡?#38171;屽綋閬囧埌鍖归厤鍏冪礌鐨?#23534;濮?#37837;?#29825;?#37724;岀粨鏉?#37837;?#29825;版椂锛宐egin()鏂规硶?#25328;end()鏂规硶灏?#37714;?#37714;?#29722;皟鐢?#37510;?

    涓鏃?#38316;囧埌鍖归厤鍏冪礌鐨?#37712;呭锛宐ody()鏂规硶琚皟鐢?#38171;?#37832;鍚?#29722;皟鐢?#37928;勬?#35268;硶鏄finish()锛?#26473;欎釜鏂规硶?#28266;鍖归厤鍏冪礌鐨勭粨鏉?#37837;?#29825;?#28598;勭?#21975;?#23678;瘯涔?#37722;?#29722;皟鐢?#38171;?#37922;?#37833;?#37813;?#29723;?#37721;兘闇瑕?#37928;勪簨鍚庢?#21615;悊浠诲姟銆傜劧鑰?#38171;?#28598;?#28598;氭暟?#26882;鍊?#37812;戜滑?#31497;蹇呭叧娉?#26473;欎簺鏂规硶锛屽洜涓烘鏋?#37819;愪緵鐨勬?#22247;噯瑙?#37714;?#23536;?#37721;兘宸?#32513;?#37819;愪緵浜嗘墍鏈夊繀闇鐨?#37716;熻兘銆?

    瑕?#37721;嶉厤鍒?#28051;?#37340;鏂囨锛?#26851;栧厛鍒涘缓涓?#37340;org.apache.commons.digester.Digester绫?#37928;?#28729;炰緥锛?#28641;?#37835;?#36423;?#29781;?#37928;?#29831;?#38171;?#26473;?#29723;?#28051;浜?#38320;嶇疆鎿?#28003;?#38171;?#37816;囧畾蹇?#38343;鐨勬寮忓拰瑙?#37714;?#38171;?#37832;鍚?#37722;parse()鏂规硶浼?#38315;?#28051;?#37340;XML鏂?#28000;?#37928;?#23534;?#37922;?#37510;?#28051;嬮潰鐨凞igesterDriver绀鸿寖浜?#26473;欎竴澶勭悊杩?#32459;?#38171;堝繀椤诲湪鍛戒护琛?#28051;?#37816;囧畾杈撳叆XML鏂囨鐨?#37722;嶇锛?#37510;?

    import org.apache.commons.digester.*;
                import java.io.*;
                import java.util.*;
                public class DigesterDriver {
                public static void main( String[] args ) {
                try {
                Digester digester = new Digester();
                digester.setValidating( false );
                digester.addObjectCreate( "catalog", Catalog.class );
                digester.addObjectCreate( "catalog/book", Book.class );
                digester.addBeanPropertySetter( "catalog/book/author", "author" );
                digester.addBeanPropertySetter( "catalog/book/title", "title" );
                digester.addSetNext( "catalog/book", "addBook" );
                digester.addObjectCreate( "catalog/magazine", Magazine.class );
                digester.addBeanPropertySetter( "catalog/magazine/name", "name" );
                digester.addObjectCreate( "catalog/magazine/article", Article.class );
                digester.addSetProperties( "catalog/magazine/article", "page", "page" );
                digester.addBeanPropertySetter( "catalog/magazine/article/headline" );
                digester.addSetNext( "catalog/magazine/article", "addArticle" );
                digester.addSetNext( "catalog/magazine", "addMagazine" );
                File input = new File( args[0] );
                Catalog c = (Catalog)digester.parse( input );
                System.out.println( c.toString() );
                } catch( Exception exc ) {
                exc.printStackTrace();
                }
                }
                }

    ?#28266;涓婇潰鐨?#28000;?#37934;?#28051;?#38171;?#37812;戜滑棣栧厛鍒涘缓浜咲igester绫?#37928;?#28051;?#37340;瀹炰緥digester锛岀劧鍚庢?#22247;畾瀹冧笉瑕?#37922;DTD楠?#29831;XML鏂囨鐨?#37722;堟硶鎬?#37413;?#37413;旇繖鏄?#37733;?#28051;?#37812;戜滑?#30149;鏈?#28051;XML鏂囨?#30078;涔DTD銆?#37818;?#28051;?#37833;?#38171;?#37812;戜滑鎸囧畾浜嗘寮忓拰鍏宠仈鐨勮鍒?#38171;歄bjectCreateRule鍒涘缓鎸囧畾绫?#37928;?#28051;?#37340;瀹炰緥锛屽苟灏嗗?#20904;?#23338;叆瑙?#37835;?#37837;?#37510;係etPropertiesRule?#22968;Bean灞?#37804;?#29825;?#32515;?#37812;?#35120;撳墠XML鍏冪礌鐨?#28766;?#37804;?#37706;?#37413;?#37413;旇鍒?#37928;?#32471;?#28051;?#37340;鍙傛暟鏄XML灞?#37804;?#37928;?#37722;嶇锛?#32471;?#27996;屼釜鍙傛暟鏄疊ean灞?#37804;?#37928;?#37722;嶇銆?

    SetPropertiesRule鑾?#37721;?#37928;?#37828;XML灞?#37804;?#37928;?#37706;?#38171;岃孊eanPropertySetterRule鑾?#37721;?#37928;?#37828;?#28003;?#27996;庡?#25779;墠鍏冪礌鍐?#37928;勫師濮?#28699;?#32471;暟鎹?#37706;?#37510;?#28003;?#37922;BeanPropertySetterRule?#26882;?#31497;蹇?#37816;囧畾瑕?#29825;?#32515;?#37928;凚ean灞?#37804;?#37722;?#28699;?#38171;岄?#27199;鏄?#35120;撳墠XML鍏冪礌鐨?#37722;嶇銆傚湪涓婇潰鐨勪緥瀛?#28051;?#38171;屽湪鍖归厤catalog/magazine/article/headline妯?#23534;?#37928;勮鍒欏畾涔?#28051;?#28003;?#37922;?#37928;勫氨鏄?#27035;樿鍊?#37510;?#37832;鍚?#38171;孲etNextRule寮?#37713;?#29785;?#37835;?#37837;?#26916;?#38318;?#37928;?#28725;硅薄锛屽?#33333;妸璇?#28725;硅薄浼?#38315;?#32513;?#28729;?#28051;嬮潰瀵硅薄鐨勬?#22247;畾鍚嶇鐨勬?#35268;硶鈥?#37413;?#38315;?#29999;?#37922;?#37833;妸涓?#37340;閰嶇疆瀹屾瘯鐨凚ean鎻掑叆鐖?#28725;硅薄銆?

    娉剰锛?#37812;戜滑鍙?#28000;?#28051;?#37722;?#28051;?#37340;妯?#23534;?#23049;?#37712;?#28598;氫釜瑙?#37714;?#37510;?#28641;?#37835;?#23049;?#37712;屼簡澶氫釜瑙?#37714;?#38171;?#37714;?#26473;欎簺瑙?#37714;?#37816;夌収瀹冧滑琚?#37716;犲叆?#22476;Digester鐨勬搴?#37813;?#29723;?#38171;?#28186;?#28641;?#38171;?#28641;?#37835;?#29781;?#28598;勭悊catalog/magazine/article鐨?article>鍏冪礌锛?#37812;戜滑棣栧厛鍒涘缓鍚?#38315;?#37928;刟rticle Bean锛岀劧鍚?#29825;?#32515;畃age灞?#37804;?#38171;?#37832;鍚庡脊鍑?#28729;?#37812;?#37722;?#37928;刟rticle Bean锛屽?#33333;妸瀹?#37819;掑叆magazine銆?

    ?#30367;鐢?#28000;绘剰鏂规硶

    鎴戜滑?#31497;浠?#37721;?#28000;?#29825;?#32515;瓸ean鐨?#28766;?#37804;?#38171;岃?#28051;旇繕鍙?#28000;皟鐢爢鏍?#37712;呭?#30789;薄鐨?#28000;绘剰鏂规硶銆?#26473;?#38315;?#26473;CallMethodRule瀹?#37812;?#38171;?#37812;戜滑鍙?#38343;鎸囧畾鏂规硶鍚?#28699;?#38171;?#28641;?#37832;夊繀瑕?#38171;?#37712;?#29831;?#37828;庤皟鐢?#37928;?#37721;傛暟绫诲?#23338;拰?#26271;閲?#37510;侰allParamRule鐢?#37833;畾涔?#28028;?#38315;?#32513;?#29722;皟鐢?#37713;芥暟鐨?#37721;傛暟鍊?#38171;?#37721;傛暟鍊?#37721;?#28000;?#28000;庡?#25779;墠XML鍏冪礌鐨?#37723;?#37722;?#37928;?#28766;?#37804;?#38014;?#37721;?#38171;屼篃鍙?#28000;?#28000;庡?#25779;墠鍏冪?#29362;?#21613;惈鐨勫師濮?#28699;?#32471;暟鎹?#38014;?#37721;?#37510;備緥濡?#38171;屽湪鍓嶉潰瀹?#37916;癉igesterDriver鐨勪緥瀛?#28051;?#38171;?#37812;戜滑鍙?#28000;笉鐢BeanPropertySetterRule锛岃?#37828;?#38315;?#26473;?#37828;?#23534;忚皟鐢?#28766;?#37804;?#37928;剆et鏂规?#26337;?#24807;埌鍚?#37837;?#37928;勭洰鐨?#38171;?

    digester.addCallMethod( "catalog/book/author", "setAuthor", 1 );
                digester.addCallParam( "catalog/book/author", 0 );

    涓婇潰鐨?#32471;?#28051;琛?#28000;?#37934;佺粰鍑?#27996;?#29781;佽皟鐢?#37928;勬?#35268;硶锛?#37719;setAuthor()锛?#38171;?#28000;?#37721;?#29831;皟鐢?#38343;瑕?#37928;?#37721;傛暟?#26271;閲?#38171;?#37719;?锛?#37510;?#32471;?#27996;?#29723;?#28000;?#37934;?#37928;勬剰鎬?#37828;?#28000;?author>鍏冪?#29362;?#21613;惈鐨?#28699;?#32471;暟鎹?#38014;?#37721;?#37713;芥暟鍙傛暟鐨?#37706;?#38171;屾妸瀹?#28003;?#28051;?#37721;傛暟?#26271;缁?#37928;?#32471;?#28051;?#37340;浼犲叆锛?#37719;崇储寮?#37828;?鐨勬暟缁?#37711;冪礌锛?#37510;?#28641;?#37835;?#37812;戜滑鎸囧畾浜XML鍏冪礌灞?#37804;?#37928;?#37722;嶇锛?#28186;?#28641;俤igester.addCallParam( "catalog/book/author", 0, "author" );锛?#38171;?#37714;?#37721;傛暟鍊?#28751;?#28000;庡?#25779;墠鍏冪礌鐨勭浉搴?#28766;?#37804;?#37706;艰幏鍙?#37510;?

    杩?#38322;屽繀椤?#23049;剰鐨?#37828;?#38171;?#8220;digester.addCallMethod( "pattern", "methodName", 0 );”杩欎釜璇?#37721;笉鏄?#37816;囧畾浜?#28051;?#37340;?#31497;甯?#37721;傛暟鐨勬?#35268;?#26337;皟鐢?#38171;岃?#37828;?#37816;囧畾浜?#29999;?#37832;?#28051;?#37340;鍙傛暟鐨勬?#35268;?#26337;皟鐢?#38171;屽畠鐨?#37706;?#28751;?#37828;?#35120;撳墠XML鍏冪礌鐨?#28699;?#32471;暟鎹?#38171;?#26473;?#37837;?#38171;?#37812;戜滑鍙?#37832;?#27996;?#37721;?#28051;绉?#37831;?#28000;BeanPropertySetterRule鐨?#37716;炴硶锛?

    digester.addCallMethod( "catalog/book/author", "setAuthor", 0 );

    濡?#37835;?#29781;佽皟鐢?#28051;?#37340;纭?#28729;炴病鏈?#37721;傛暟鐨勬?#35268;硶锛屽繀椤婚噰鐢?#28641;?#28051;?#35120;?#23534;?#38171;歞igester.addCallMethod( "pattern", "methodName" );銆?

    鏍囧噯瑙?#37714;?#22994;?#29781;?

    涓嬮潰绠瑕?#29831;?#37828;庢墍鏈?#37837;囧噯瑙?#37714;?#37510;?

    鍒涘缓

    ObjectCreateRule锛?#37714;?#37922;?#37816;囧畾绫?#37928;勯?#27199;鏋勯?#37713;芥暟锛?#37714;涘缓璇?#32491;?#37928;?#28051;?#37340;瀵硅薄锛屽?#33333;妸瀵硅薄鍘嬪叆鏍?#37510;?#35120;撳?#20906;礌澶勭?#21977;粨鏉熸椂锛屽?#30789;薄琚?#23534;?#37713;?#37510;?#29722;?#28729;炰?#23338;寲鐨勭被鍙?#38315;?#26473;class瀵硅薄鎴?#32491;?#37928;?#37711;?#32457;?#32513;?#37713;?#37510;?

    FactoryCreateRule锛?#37714;?#37922;?#37816;囧畾鐨勫伐鍘?#32491;?#37714;涘缓涓?#37340;瀵硅薄锛屾妸瀵硅薄鍘嬪叆鏍?#37510;?#28725;?#27996;庢病鏈?#37819;愪緵榛樿鏋勯?#37713;芥暟鐨勭被锛?#26473;欎竴瑙?#37714;?#23536;?#37832;?#37922;?#37510;?#37922;?#27996;?#29831;?#29785;?#37714;?#37928;勫伐鍘?#32491;诲繀椤诲疄鐜org.apache.commons.digester.ObjectCreationFactory鎺?#37721;?#37510;?

    璁?#32515;?#28766;?#37804;?

    SetPropertiesRule锛?#37714;?#37922;?#37816;囧畾鍚嶇鐨刋ML鍏冪礌灞?#37804;?#37706;?#38171;?#29825;?#32515;?#26916;?#28766;侭ean鐨?#28051;?#37340;鎴?#38000;?#28598;氫釜鎸囧畾鍚嶇鐨?#28766;?#37804;?#37510;俋ML鍏冪礌鐨?#28766;?#37804;?#37722;嶇?#26495;拰Bean鐨?#28766;?#37804;?#37722;嶇浠String[]?#26271;缁?#35120;?#23534;?#28028;犲叆璇?#29785;?#37714;?#38171;?#38315;?#29999;?#37922;?#37833;?#28598;勭悊

    涔?#32491;?#37928;勭粨鏋?#38171;?#37510;?

    BeanPropertySetterRule锛氭妸椤?#28766;侭ean鐨勬?#22247;畾鍚嶇鐨?#28766;?#37804;?#29825;?#32515;?#37812;?#35120;撳墠XML鍏冪?#29362;?#21613;惈鐨?#28699;?#32471;暟鎹?#37510;?#38171;?#38315;?#29999;?#37922;?#37833;?#28598;勭悊<page>10</page>涔?#32491;?#37928;勭粨鏋?#38171;?#37510;?

    SetPropertyRule锛?#29825;?#32515;?#26916;?#28766;侭ean鐨?#28051;?#37340;灞?#37804;?#37510;?#37827;?#29825;?#37828;疊ean灞?#37804;?#37928;?#37722;嶇锛?#26473;?#37828;?#29863;?#27996;?#29831;?#28766;?#37804;?#37928;?#37706;?#38171;?#38318;藉湪褰撳墠XML鍏冪礌涓?#28000;?#28766;?#37804;?#37928;?#35120;?#23534;?#37816;囧畾锛?#28186;?#28641;?#38171;?ccid_code><article key="page" value="10" />銆?

    绠?#37918;嗙埗/瀛?#37711;崇郴

    SetNextRule锛?#23534;?#37713;?#37837;?#26916;?#37928;?#28725;硅薄锛屾妸瀹?#28028;?#38315;?#32513;欑揣鎺?#37711;?#28051;?#37928;?#37721;?#28051;?#37340;瀵硅薄鐨勬?#22247;畾鍚嶇鐨勬?#35268;硶銆傞?#29999;?#37922;?#37833;妸涓?#37340;宸?#32513;?#37714;?#28654;嬪寲鐨凚ean鎻掑叆?#22476;鐖?#28725;硅薄銆?

    SetTopRule锛氭妸鏍?#38322;岄潰涓婃暟绗?#27996;?#37928;?#28725;硅薄浼?#38315;?#32513;?#26916;?#28766;?#37928;?#28725;硅薄銆?#35120;?#28699;?#28725;硅薄鎻愪緵浜?#28051;?#37340;setParenet鏂规硶?#26882;锛?#26473;欎竴瑙?#37714;?#23536;?#37832;?#37922;?#37510;?

    SetRootRule锛氳皟鐢?#37837;?#25652;曞?#30789;薄鐨?#28051;?#37340;鏂规硶锛屽?#33333;妸鏍?#26916;?#37928;?#28725;硅薄浣?#28051;?#37721;傛暟浼犲叆銆?

    ?#30367;鐢?#28000;绘剰鏂规硶

    CallMethodRule锛氳皟鐢?#26916;?#28766;侭ean鐨勬?#22247;畾鍚嶇鐨勬?#35268;硶銆?#29722;皟鐢?#37928;勬?#35268;硶鍙?#28000;?#37832;?#28000;绘剰澶氫釜鍙傛暟锛?#37721;傛暟鐨?#37706;?#38315;?#26473;囧悗缁?#37928;凜allParamRule缁?#37713;?#37510;?

    CallParamRule锛?#29723;?#32448;?#37826;规?#26337;皟鐢?#37928;?#37721;傛暟銆?#37721;傛暟鐨?#37706;?#37812;?#38000;?#37721;?#38007;?#37816;囧畾鍚嶇鐨刋ML鍏冪礌鐨?#28766;?#37804;?#38171;?#37812;?#38000;?#37828;?#35120;撳墠鍏冪?#29362;?#21613;惈鐨勫師濮?#28699;?#32471;暟鎹?#37510;?#26473;欎釜瑙?#37714;?#29781;佹眰鐢?#28051;?#37340;鏁存暟鎸囧畾瀹冨湪鍙傛暟鍒?#29723;?#28051;?#37928;?#28003;嶇疆銆?

    閫?#26473;XML鎸囧畾瑙?#37714;?

    ?#28266;鍓嶉潰鐨?#37712;呭涓?#38171;?#37812;戜滑鐢?#32459;?#25652;?#28000;?#37934;?#37928;勬柟寮?#37816;囧畾妯?#23534;忓拰瑙?#37714;?#38171;?#26473;欎簺妯?#23534;忓拰瑙?#37714;?#38318;?#37828;湪缂?#29831;?#37928;勬椂鍊?#28751;卞凡缁?#32429;畾锛岃?#30028;劧浠庢?#20634;康涓?#37833;?#29825;?#23011;旇?#20906;畝鍗?#38171;?#28003;?#37719;翠笉?#20824;璇?#28751;藉?#21227;?#30028;锛欴igester妗?#37835;?#37928;勬?#28003;撶洰鏍?#37828;湪杩?#29723;屾椂璇?#37714;拰澶勭悊鍚勭?#23942;暟鎹粨鏋?#38171;?#28003;?#28641;?#37835;?#37812;戜滑鐢?#32514;?#32459;?#37928;勬?#35268;硶鎸囧畾妯?#23534;忓拰瑙?#37714;?#38171;?#37714;欐墍鏈?#29723;?#28051;哄湪缂?#29831;戞椂宸?#32513;忓?#21700;畾锛?#28641;?#37835;Java婧愮搴?#28051;?#37718;呭惈浜?#28598;?#38322;忓?#21700;畾鐨?#28699;?#32471;?#28051;?#38171;岄?#29999;告剰鍛崇潃绋?#25652;忓湪鎵?#29723;?#37836;愪簺閰嶇疆鎿?#28003;?#38171;?#26473;?#38318;?#37714;嗘搷浣?#37721;?#28000;?#29722;?#38171;?#37812;?#29825;?#37828;?#25652;旇琚?#38171;夊欢杩熷埌杩?#29723;屾椂杩?#29723;?#37510;?

    org.apache.commons.digester.xmlrules鍖?#29785;喅浜?#26473;欎釜闂?#26864;?#37510;?#26473;欎釜鍖?#37819;愪緵浜?#28051;?#37340;DigesterLoader绫?#38171;屽畠?#20824;澶?#28000;嶺ML鏂囨璇?#37721;?#22959;?#23534;?瑙?#37714;?#28725;?#38171;?#26473;?#37733;?#38320;嶇疆濂?#37928;凞igester瀵硅薄銆?#37922;?#37833;?#38320;嶇疆Digester瀵硅薄鐨刋ML鏂囨蹇?#26916;?#38316;?#28000;巇igester-rules.dtd锛?#26473;欎釜DTD鏄痻mlrules鍖?#37928;?#28051;閮?#37714;?#37510;?

    涓嬮潰灏?#37828;?#37832;?#37826;?#28186;?#28699;?#37928;勯?#23943;疆鏂?#28000;秗ules.xml銆?#37832;?#37713;?#37904;瑰繀椤?#29831;?#37828;?#37510;?

    棣栧厛锛屾寮?#37721;?#28000;?#37922;?#28051;?#32457;?#37826;?#23534;?#37816;囧畾锛?#37812;?#38000;?#28003;?#37922;?ccid_code><pattern>鍏冪礌锛?#37812;?#38000;?#38315;?#26473;?#28000;?#29723;?#29785;?#37714;?#37928;刋ML鍏冪礌鐨?#28766;?#37804;?#37510;?#26473;欎袱绉?#37716;炴硶鍙?#28000;?#23075;?#37722;?#28003;?#37922;?#38171;?#28051;?ccid_code><pattern>鍏冪礌鏄?#37721;?#28000;?#23443;屽鐨?#37510;?#37711;?#23046;?#38171;?ccid_code><alias>鍏冪?#29362;拰<set-properties-rule>涓璧蜂娇鐢?#38171;?#37922;?#37833;妸XML灞?#37804;?#37828;犲?#21227;埌Bean灞?#37804;?#37510;?#37832;鍚?#38171;屽氨褰撳墠鍙戣鐨凞igester杞?#28000;?#37718;?#38000;岃锛?#37812;戜滑?#31497;?#20824;?#28266;閰嶇疆鏂?#28000;?#28051;?#37816;囧畾BeanPropertySetterRule锛屾濡?#37715;嶉潰?#22669;浠?#32513;?#37928;?#38171;?#37812;戜滑鐢CallMethodRule鏉?#26440;惧埌鍚?#37837;?#37928;勭洰鏍?#37510;?

    <?xml version="1.0"?>
                <digester-rules>
                <object-create-rule pattern="catalog" classname="Catalog" />
                <set-properties-rule pattern="catalog" >
                <alias attr-name="library" prop-name="library" />
                </set-properties-rule>
                <pattern value="catalog/book">
                <object-create-rule classname="Book" />
                <call-method-rule pattern="author" methodname="setAuthor"
                paramcount="0" />
                <call-method-rule pattern="title" methodname="setTitle"
                paramcount="0" />
                <set-next-rule methodname="addBook" />
                </pattern>
                <pattern value="catalog/magazine">
                <object-create-rule classname="Magazine" />
                <call-method-rule pattern="name" methodname="setName" paramcount="0" />
                <pattern value="article">
                <object-create-rule classname="Article" />
                <set-properties-rule>
                <alias attr-name="page" prop-name="page" />
                </set-properties-rule>
                <call-method-rule pattern="headline" methodname="setHeadline"
                paramcount="0" />
                <set-next-rule methodname="addArticle" />
                </pattern>
                <set-next-rule methodname="addMagazine" />
                </pattern>
                </digester-rules>

    鐜板湪锛屾墍鏈夊疄闄?#37928;勬搷浣?#38318;借浆绉诲埌浜咲igester?#25328;DigesterLoader绫?#38171;孹mlRulesDriver绫诲氨鍙?#23536;楃浉褰撶畝鍗?#37510;?#26473;?#29723;?#28051;嬮潰鐨刋mlRulesDriver?#26882;锛屽湪绗?#28051;?#37340;鍛戒护琛?#37721;傛暟涓?#37816;囧畾?#27952;褰?#37826;囨鐨?#37722;?#28699;?#38171;屽湪绗?#27996;屼釜鍙傛暟涓?#37816;囧畾rules.xml锛?#23049;剰锛孌igesterLoader?#31497;鏄?#28000;嶧ile鎴?#38000;卭rg.xml.sax.InputSource璇?#37721;rules.xml鏂?#28000;?#38171;岃?#37828;?#29781;佹眰鎸囧畾涓?#37340;URL锛屽洜姝?#38171;?#28051;嬮潰浠?#37934;?#28051;璅ile寮?#37922;?#29722;浆?#23858;鎴愪?#21977;瓑浠?#37928;刄RL锛?#37510;?

    import org.apache.commons.digester.*;
                import org.apache.commons.digester.xmlrules.*;
                import java.io.*;
                import java.util.*;
                public class XmlRulesDriver {
                public static void main( String[] args ) {
                try {
                File input = new File( args[0] );
                File rules = new File( args[1] );
                Digester digester = DigesterLoader.createDigester( rules.toURL() );
                Catalog catalog = (Catalog)digester.parse( input );
                System.out.println( catalog.toString() );
                } catch( Exception exc ) {
                exc.printStackTrace();
                }
                }
                }

    ?#31912;鏉?#29831;?#38171;?#37832;?#37826;囧?#31551;akarta Commons Digester鐨?#28000;?#32513;?#28751;卞埌杩?#38322;岀粨鏉?#37510;?#35120;撶劧锛?#26473;?#37832;?#29825;?#28598;?#37712;呭杩?#38322;屽皻鏈?#23057;?#37721;?#37510;?#37711;?#28051;?#28051;?#37340;?#28266;杩?#38322;屽?#30028;暐鐨?#28051;?#26864;?#37828;XML鍚嶇?#25198;闂?#38171;欴igester鍏?#29825;告妸瑙?#37714;欏畾涔?#37812;?#37721;兘瀵规煇涓?#37340;鍚嶇?#25198;闂?#37712;呭畾涔?#37928;?#37711;冪礌璧蜂綔鐢?#37510;?

    鍙?#28598;?#38171;?#37812;戜滑绠鍗曞湴鎻?#37721;?#27996;?#38315;?#26473;?#37813;?#28766;Rule绫?#23534;鍙戝畾鍒?#29785;?#37714;?#37928;?#38338;?#26864;?#37510;?#37816;夌収?#31684;鎯?#38171;孌igester绫?#37819;愪緵浜唒ush()銆乸eek()?#25328;pop()鏂规硶锛?#28003;?#23536;楀紑鍙戣呰兘澶?#38007;?#37922;卞湴鐩?#37818;?#37823;?#28003;?#29785;?#37835;?#37837;?#37510;?

    鍙?#38000;?#38171;?/strong>

    Jakarta Commons Digester Homepage

    Jakarta Struts Homepage



    ]]>ThreadLocal涓巗ynchronized http://www.67529968.com/lingy/archive/2009/08/25/292559.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Tue, 25 Aug 2009 12:36:00 GMThttp://www.67529968.com/lingy/archive/2009/08/25/292559.html?#27977;鍏?#37826;?#32468;?  
    姝?#32429;?#37918;?#29785;ThreadLocal
    ThreadLocal涓巗ynchronized

    鎺?#38013;?#37734;?#28699;? Pipboy
    鏇?#28598;氱浉鍏?#37818;?#38013;?
    鏄?#28598;?#28051;奐ava鐗堝潡閫?#27996;?#28051;鍦?#38171;?#28051;?#37340;2涓?鍗?#27996;?#23092;?#29785;?#37928;?#29999;?#28699;?#23534;?#29863;蜂?#21975;?#33333;淮娉剰 ThreadLocal涓巗ynchronized 锛?椤?#28000;?#28051;?#37928;勫洖澶?#38171;岃冻瑙?#28598;?#28729;?#28725;?#26473;欎釜闂?#26864;?#37928;?#37711;?#29906;?#37510;?

    鑰?#28729;?#29831;?#38171;?#28000;庣湅?#22476;杩欎釜甯?#28699;?#37928;?#26864;樼洰寮濮?#38171;屽氨瑙夊?#26944;笘瀛?#37928;?#28003;?#38000;?#28028;拌鏄湪姒傚康涓?#37832;夋墍娣锋?#21973;簡,浜?#37828;?#28052;?#37807;?#37712;欎釜鍜氬挌锛?#37722;?#28598;?#28729;?#37714;嗕韩涓涓嬭嚜?#32321;鐨勫績寰?#37510;?

    甯?#28699;?#28051;?#38171;?#29825;?#29825;?#37928;勪汉寰?#28598;?#38171;岄珮鎵嬩笉涔?#38171;?#37722;勬?#25489;繁瑙?#38171;?#28003;嗕笉?#29025;鏂?#37813;嬩滑?#28229;鏄?#37927;芥病鏈?#38171;屽洜姝?#38171;?#26473;?#38322;屽伓浠?#37832;绠娲?#37714;?#29723;?#37826;?#23534;?#37833;?#29831;?#28051;璇寸浉鍏?#38338;?#26864;?#37510;?

    1锛庡尯鍒玊hreadLocal 涓?synchronized

    ThreadLocal鏄?#28051;?#37340;?#22158;绋嬮?#26050;(鎴?#38000;?#29831;?#37828;嚎绋嬪?#22794;叏)鐨?#37721;?#38322;?#28699;樺偍鐨勭鐞嗗疄浣?#38171;?#23049;剰锛氫笉鏄?#28699;樺偍鐢?#37928;?#38171;?#38171;屽畠浠Java绫?#37826;?#23534;?#29723;?#37916;?#38171;?
    synchronized鏄疛ava鐨?#28051;?#37340;淇濈暀瀛?#38171;?#37721;?#37828;?#28051;?#37340;浠?#37934;?#37837;?#29831;?#32471;?#38171;屽畠渚?#38344;JVM鐨勯攣鏈?#37714;?#37833;?#28729;?#37916;?#28051;寸?#23677;尯鐨?#37713;芥暟銆?#37721;?#38322;忓湪CPU杩?#29723;?#29825;?#38338;?#28051;?#37928;勫師瀛?#37804;?#37510;?
    涓?#38000;?#37928;勬?#29840;?#37510;?#29723;?#37916;?#37721;?#29825;?#29825;?#37714;?#29723;蜂笉鍚?#38171;屽洜姝病鏈?#37721;?#23011;旇緝鎬?#37510;?

    2.鐞?#29785;ThreadLocal涓?#37819;愬埌鐨?#37721;?#38322;?#37715;?#37832;?
    浜嬪疄涓?#38171;?#37812;戜滑鍚慣hreadLocal涓璼et鐨?#37721;?#38322;忎笉鏄?#37922;ThreadLocal鏉?#28699;樺偍鐨?#38171;岃?#37828;Thread?#22158;绋?#28725;硅薄鑷?#38892;?#28103;?#28699;?#37510;?#35120;?#37922;?#37812;疯皟鐢ThreadLocal瀵硅薄鐨剆et(Object o)?#26882;锛?#29831;?#37826;规硶鍒?#38315;?#26473;Thread.currentThread()鑾?#37721;栧?#25779;墠?#22158;绋?#38171;屽皢鍙?#38322;?#28699;樺叆Thread涓?#37928;?#28051;?#37340;Map鍐?#38171;岃孧ap鐨凨ey灏?#37828;?#35120;撳墠鐨凾hreadLocal瀹炰緥銆?#29831;风湅婧愮爜锛?#26473;?#37828;?#37832;涓?#29781;?#37928;?#28051;釜鍑芥暟锛岃兘?#28229;鍑篢hreadLocal涓嶵hread鐨勮皟鐢?#37711;崇郴锛?

    Java浠?#37934;?
    public void set(T value) {   
            Thread t = Thread.currentThread();   
            ThreadLocalMap map = getMap(t);   
            if (map != null)   
                map.set(this, value);   
            else  
                createMap(t, value);   
    }   
      
    ThreadLocalMap getMap(Thread t) {   
            return t.threadLocals;   
    }  
    public void set(T value) {
            Thread t = Thread.currentThread();
            ThreadLocalMap map = getMap(t);
            if (map != null)
                map.set(this, value);
            else
                createMap(t, value);
    }

    ThreadLocalMap getMap(Thread t) {
            return t.threadLocals;
    }

    锛?#37832;夊叴瓒?#37928;勬湅鍙?#37721;?#28000;?#38339;?#29831;籎ava鐨凾hreadLocal婧愮爜锛夊洜姝?#38171;?#37812;戜滑鍙?#28000;煡閬?#38171;屾墍璋?#37928;?#37721;?#38322;?#37715;?#37832;?#38171;?#37719;?#37828;?#28725;Object Reference锛?#28725;硅薄寮?#37922;?#38171;?#37928;勬嫹璐?#37510;?

    3.鐞?#29785;Thread?#25328; ThreadLocal瀵?#37721;?#38322;?#37928;?#23534;?#37922;?#37711;崇郴
    瀹?#38340;?#28051;奣hread?#25328;ThreadLocal瀵?#37721;?#38322;?#23534;?#37922;?#37711;崇?#35826;?#21342;儚鏄?#37735;?#37837;?#32495;?#28051;?#37928;刋杞村拰Y杞?#38171;?#37828;?#28000;?#28051;釜缁?#25652;?#28051;?#37833;?#32513;?#32513;囧鍙?#38322;?#37928;?#23534;?#37922;?#37928;?#37510;?

    棣栧厛璇碩hread銆?鎴戜滑?#29025;閬?#28051;?#37340;ThreadOne鐨勬墽琛屼細璐?#32460;?#28598;氫釜鏂规硶MethodA銆丮ethodB銆丮ethodC杩欎簺鏂规硶鍙兘鍒?#29999;?#27996;庝笉鍚?#37928;勭?#35826;?#28848;緥銆傚亣璁?#38171;?#26473;欎簺鏂规硶鍒?#37714;?#28003;?#37922;?#27996;員hreadLocalA銆乀hreadLocalB銆乀hreadLocalC鏉?#28103;?#28699;樼嚎绋?#37832;?#37734;?#37721;?#38322;?#38171;岄偅涔?#26473;欎簺鍙?#38322;?#38318;?#28699;?#27996;嶵hreadOne鐨凪ap涓?#38171;屽苟浣?#37922;?#37722;勮嚜鐨凾hreadLocal瀹炰緥浣?#28051;key銆?鍥?#23005;?#38171;?#37721;?#28000;?#29825;?#28051;?#38171;?#37706;?#37716;ThreanLocal鐨剆et鏂规硶锛屽湪X杞?#28051;?#38171;孴hread妯?#37722;?#37711;宠仈鍚?#28051;?#22158;绋?#28051;?#28051;?#37826;?#28051;?#37833;?#38007;?#28598;氫釜Method鐨?#37721;?#38322;?#23534;?#37922;?#37715;?#37832;?#37510;?


     


    鎺潃璇碩hreadLocal銆?涓?#37340;MethodA涓?#37928;刋鍙?#38322;?#28751;?#29722;?#28598;氫釜?#22158;绋婽hreadOne銆乀hreadTwo銆乀hreadThree?#22669;璁?#38338;?#37510;傚亣璁綧ethodA浣?#37922;ThreadLocal瀛樺偍X锛岄?#26473;set鏂规硶锛?#28000;ThreadLocal浣?#28051;key鍊?#38171;屽?#21973;笉鍚岀嚎绋?#37833;?#29825;挎椂鐨勪笉鍚?#37928;?#37721;?#38322;?#37706;?#23534;?#37922;?#28103;?#28699;?#27996;嶵hreadOne銆乀hreadTwo銆乀hreadThree鐨?#37722;勮嚜?#22158;绋?#28051;?#28051;?#37826;?#28051;?#38171;?#32429;?#28103;?#23011;忎釜?#22158;绋?#37832;?#38007;繁鐨?#28051;?#37340;鍙?#38322;?#37706;?#37510;?#37733;?#23005;?#38171;?#37721;?#28000;?#29825;?#28051;?#38171;孴hreadLocal鏄?#28000;Method涓篩杞?#38171;岀旱鍚?#37711;宠仈浜?#28598;勪簬鍚?#28051;鏂规硶涓?#37928;勪笉鍚岀嚎绋?#28051;?#37928;?#37721;?#38322;?#37510;?


     

    甯?#37832;涜兘瀵?#28598;?#28729;?#37832;夋墍甯?#37716;?#38171;?#26473;?#37837;?#37721;?#28000;?#28751;戣蛋寰?#28598;?#23534;矾鍝?#37510;?

    鏈?#37826;?#37833;?#38007;狢SDN鍗?#28729;?#38171;岃浆杞?#29831;?#37837;?#37828;?#37713;?#28598;?#38171;歨ttp://blog.csdn.net/yangairong1984/archive/2008/04/15/2294572.aspx



    ]]>
    鐞?#29785;ThreadLocal http://www.67529968.com/lingy/archive/2009/08/25/292558.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Tue, 25 Aug 2009 12:35:00 GMThttp://www.67529968.com/lingy/archive/2009/08/25/292558.htmlThreadLocal鏄?#28000;涔?/p>

    鏃湪JDK 1.2鐨勭増鏈?#28051;?#28751;?#37819;愪緵java.lang.ThreadLocal锛孴hreadLocal涓?#29785;喅澶氱嚎绋?#32459;?#25652;?#37928;勫苟鍙?#38338;?#26864;?#37819;愪緵浜?#28051;绉?#37826;?#37928;勬濊矾銆?#28003;?#37922;?#26473;欎釜宸?#37711;风被鍙?#28000;?#23536;堢畝娲佸?#25198;紪鍐?#37713;?#28028;樼鐨?#28598;氱嚎绋?#32459;?#25652;?#37510;?/p>

    ThreadLocal寰?#28729;?#37828;?#29825;?#27996;?#37832;?#37826;?#37922;?#28052;?#38171;?#37807;冲綋?#21159;鍦拌涓?#37828;?#28051;?#37340;“鏈?#37734;扮嚎绋?#8221;銆?#37711;?#28729;?#38171;孴hreadLocal骞朵笉鏄?#28051;?#37340;Thread锛岃?#37828;Thread鐨?#28766;閮?#37721;?#38322;?#38171;屼篃璁告妸瀹?#37723;?#37722;?#28051;篢hreadLocalVariable鏇?#28729;?#37828;?#29825;?#27996;虹悊瑙?#28051;浜?#37510;?/p>

    褰?#28003;?#37922;ThreadLocal缁存姢鍙?#38322;忔椂锛孴hreadLocal涓?#23011;忎釜浣?#37922;?#29831;?#37721;?#38322;?#37928;勭嚎绋?#37819;愪?#28058;嫭绔?#37928;?#37721;?#38322;?#37715;?#37832;?#38171;屾墍浠?#23011;?#28051;?#37340;?#22158;绋?#38318;?#37721;?#28000;嫭绔嬪?#29256;敼鍙樿嚜?#32321;鐨勫壇鏈?#38171;岃屼笉?#32048;褰卞搷鍏?#28729;冪嚎绋嬫墍瀵?#25652;?#37928;勫壇鏈?#37510;?/p>

    浠庣嚎绋?#37928;勮搴湅锛岀洰鏍?#37721;?#38322;?#28751;辫薄鏄嚎绋?#37928;勬湰鍦?#37721;?#38322;?#38171;?#26473;欎篃鏄?#32491;?#37722;?#28051;?#8220;Local”?#22669;瑕?#29723;?#26440;?#37928;勬剰鎬?#37510;?/p>

    ?#22158;绋?#28766;閮?#37721;?#38322;?#39582;朵笉鏄疛ava鐨勬柊鍙?#37828;?#38171;屽緢澶?#29831;?#29815;锛?#28641;IBM IBM XL FORTRAN锛夊湪璇硶灞傞潰灏?#37819;愪?#28058;嚎绋?#28766;閮?#37721;?#38322;?#37510;傚湪Java涓病鏈?#37819;愪?#28056;湪璇?#29815;?#39559;鏀?#37816;?#38171;岃?#37828;?#37721;樼浉鍦?#38315;?#26473;ThreadLocal鐨勭被鎻愪緵鏀?#37816;?#37510;?/p>

    ?#22669;浠?#38171;屽湪Java涓?#32514;?#37712;欑嚎绋?#28766;閮?#37721;?#38322;?#37928;?#28000;?#37934;佺浉瀵?#37833;?#29831;?#29781;?#32471;?#37815;欎竴浜?#38171;屽洜姝?#38315;?#37812;愮嚎绋?#28766;閮?#37721;?#38322;忔病鏈夊湪Java寮鍙戣?#28051;?#23536;楀埌寰?#28610;?#37928;勬櫘鍙?#37510;?/p>

    ThreadLocal鐨勬帴鍙?#37826;规硶

    ThreadLocal绫?#37818;?#37721;?#23536;堢畝鍗?#38171;?#37721;?#37832;??#37340;鏂规硶锛?#37812;戜滑?#21403;鏉?#27996;?#29785;?#28051;涓?#38171;?/p>

    void set(Object value)
    璁?#32515;?#35120;撳墠?#22158;绋?#37928;勭嚎绋?#28766;閮?#37721;?#38322;?#37928;?#37706;?#37510;?/p>

    public Object get()
    璇?#37826;规硶杩?#37733;?#35120;撳墠?#22158;绋嬫墍瀵?#25652;?#37928;勭嚎绋?#28766;閮?#37721;?#38322;?#37510;?/p>

    public void remove()
    灏?#35120;撳墠?#22158;绋?#28766;閮?#37721;?#38322;?#37928;?#37706;?#37714;犻櫎锛岀洰鐨?#37828;?#28051;?#27996;?#37713;?#28751;?#37712;?#28699;?#37928;勫崰鐢?#38171;?#29831;?#37826;规硶鏄疛DK 5.0鏂?#28583;?#37928;勬?#35268;硶銆?#38343;瑕?#37816;囧嚭鐨?#37828;?#38171;屽綋?#22158;绋嬬粨鏉?#37722;?#38171;屽搴旇?#22158;绋?#37928;?#28766;閮?#37721;?#38322;?#28751;?#38007;姩琚?#37736;冨溇鍥?#37824;?#38171;屾墍浠?#37828;?#23534;忚皟鐢?#29831;?#37826;规硶娓呴櫎?#22158;绋?#37928;?#28766;閮?#37721;?#38322;?#39582;朵笉鏄?#36423;?#26916;?#37928;勬搷浣?#38171;?#28003;嗗畠鍙?#28000;?#37716;犲揩鍐?#28699;樺洖鏀?#37928;勯?#25652;?#37510;?/p>

    protected Object initialValue()
    杩?#37733;?#29831;嚎绋?#28766;閮?#37721;?#38322;?#37928;?#37714;?#28654;?#37706;?#38171;?#29831;?#37826;规硶鏄?#28051;?#37340;protected鐨勬?#35268;硶锛?#37828;剧劧鏄?#28051;?#27996;?#29825;?#28699;愮被瑕?#37929;?#38000;?#29825;?#29825;?#37928;?#37510;?#26473;欎釜鏂规硶鏄?#28051;?#37340;?#27426;杩熻皟鐢?#37826;规硶锛屽湪?#22158;绋?#32471;?娆皟鐢get()鎴杝et(Object)?#26882;鎵嶆墽琛?#38171;屽苟涓?#28000;?#37813;?#29723;?娆?#37510;俆hreadLocal涓?#37928;勭?#34425;渷瀹?#37916;?#37929;?#37818;?#26473;?#37733;?#28051;?#37340;null銆?/p>

    鍊?#23536;?#28051;鎻?#37928;?#37828;?#38171;屽湪JDK5.0涓?#38171;孴hreadLocal宸?#32513;?#37824;?#37816;?#23049;涘瀷锛?#29831;?#32491;?#37928;勭被鍚?#23480;?#32513;?#37721;?#28051;篢hreadLocal<T>銆侫PI鏂规硶涔熺浉搴旇繘琛屼簡?#30367;鏁?#38171;?#37826;?#37911;?#37832;?#37928;凙PI鏂规硶鍒?#37714;?#37828;痸oid set(T value)銆乀 get()浠?#37721;奣 initialValue()銆?/p>

    ThreadLocal鏄?#28641;?#28003;曞?#27692;埌涓?#23011;?#28051;?#37340;?#22158;绋?#32513;存姢鍙?#38322;?#37928;勫壇鏈?#37928;?#37723;紵鍏?#28729;?#28729;?#37916;?#37928;勬濊矾寰堢畝鍗?#38171;氬湪ThreadLocal绫?#28051;?#37832;?#28051;?#37340;Map锛?#37922;?#27996;?#28699;樺偍姣?#28051;?#37340;?#22158;绋?#37928;?#37721;?#38322;?#37715;?#37832;?#38171;孧ap涓?#37711;冪礌鐨勯敭涓虹嚎绋?#28725;硅薄锛岃?#37706;?#28725;?#25652;旂嚎绋?#37928;?#37721;?#38322;?#37715;?#37832;?#37510;?#37812;戜滑鑷?#23480;卞氨鍙?#28000;?#37819;愪緵涓?#37340;绠鍗?#37928;?#28729;?#37916;?#37911;?#37832;?#38171;?/p>

    浠?#37934;佹?#21613;崟1 SimpleThreadLocal

    public class SimpleThreadLocal {

    private Map valueMap = Collections.synchronizedMap(new HashMap());

    public void set(Object newValue) {

    valueMap.put(Thread.currentThread(), newValue);鈶犻敭涓虹嚎绋?#28725;硅薄锛?#37706;?#28051;?#37832;嚎绋?#37928;?#37721;?#38322;?#37715;?#37832;?/p>

    }

    public Object get() {

    Thread currentThread = Thread.currentThread();

    Object o = valueMap.get(currentThread);鈶?#26473;?#37733;?#37832;嚎绋?#28725;?#25652;?#37928;?#37721;?#38322;?/p>

    if (o == null && !valueMap.containsKey(currentThread)) {?#25023;濡?#37835;滃湪Map涓笉瀛樺湪锛?#37824;惧埌Map

    涓?#28103;?#28699;?#29863;?#37833;?#37510;?/p>

    o = initialValue();

    valueMap.put(currentThread, o);

    }

    return o;

    }

    public void remove() {

    valueMap.remove(Thread.currentThread());

    }

    public Object initialValue() {

    return null;

    }

    }

    铏界劧浠?#37934;佹?#21613;崟9鈥?杩欎釜ThreadLocal瀹?#37916;?#37911;?#37832;?#37828;?#23536;?#23011;旇緝骞?#32459;?#38171;?#28003;嗗?#20904;拰JDK?#22669;鎻愪緵鐨凾hreadLocal绫诲湪瀹?#37916;?#37804;濊矾涓?#37828;?#37929;歌繎鐨?#37510;?/p>

    涓?#37340;TheadLocal瀹炰緥

    涓嬮潰锛?#37812;戜滑閫?#26473;?#28051;?#37340;鍏蜂綋鐨?#28729;炰緥浜?#29785;?#28051;涓婽hreadLocal鐨?#37711;蜂綋浣?#37922;?#37826;规硶銆?/p>

    浠?#37934;佹?#21613;崟2 SequenceNumber

    package com.baobaotao.basic;

    public class SequenceNumber {

    鈶?#38315;?#26473;囧尶鍚?#37712;?#38318;?#32491;?#29781;?#37929;朤hreadLocal鐨刬nitialValue()鏂规硶锛?#37816;囧畾鍒?#28654;?#37706;?/p>

    private static ThreadLocal<Integer> seqNum = new ThreadLocal<Integer>(){

    public Integer initialValue(){

    return 0;

    }

    };

    鈶?#38014;?#37721;?#28051;?#28051;?#37340;搴?#37714;楀?/p>

    public int getNextNum(){

    seqNum.set(seqNum.get()+1);

    return seqNum.get();

    }

    public static void main(String[] args)

    {

    SequenceNumber sn = new SequenceNumber();

    ?#25023; 3?#37340;?#22158;绋?#37711;?#27996;玸n锛?#37722;勮嚜?#39559;鐢?#25652;?#37714;楀彿

    TestClient t1 = new TestClient(sn);

    TestClient t2 = new TestClient(sn);

    TestClient t3 = new TestClient(sn);

    t1.start();

    t2.start();

    t3.start();

    }

    private static class TestClient extends Thread

    {

    private SequenceNumber sn;

    public TestClient(SequenceNumber sn) {

    this.sn = sn;

    }

    public void run()

    {

    for (int i = 0; i < 3; i++) {鈶?#23011;忎釜?#22158;绋?#37813;?#37713;??#37340;搴?#37714;楀?/p>

    System.out.println("thread["+Thread.currentThread().getName()+

    "] sn["+sn.getNextNum()+"]");

    }

    }

    }

    }

     
    閫?#29999;?#37812;戜滑閫?#26473;囧尶鍚?#37712;?#38318;?#32491;?#37928;勬柟寮忓畾涔ThreadLocal鐨?#28699;愮被锛?#37819;愪緵鍒?#28654;?#37928;?#37721;?#38322;?#37706;?#38171;?#28641;備緥瀛?#28051;?#37430;?#28598;勬墍绀?#37510;俆estClient?#22158;绋嬩骇鐢?#28051;缁?#25652;?#37714;楀彿锛屽湪?#25023;澶?#38171;?#37812;戜滑鐢?#37812;??#37340;TestClient锛屽?#20903;滑鍏?#27996;?#37722;?#28051;?#37340;SequenceNumber瀹炰緥銆?#26473;?#29723;?#28000;?#28051;?#28000;?#37934;?#38171;屽湪鎺?#37714;?#37721;?#28051;?#26440;?#37713;?#28000;?#28051;?#37928;勭粨鏋?#38171;?/p>

    thread[Thread-2] sn[1]

    thread[Thread-0] sn[1]

    thread[Thread-1] sn[1]

    thread[Thread-2] sn[2]

    thread[Thread-0] sn[2]

    thread[Thread-1] sn[2]

    thread[Thread-2] sn[3]

    thread[Thread-0] sn[3]

    thread[Thread-1] sn[3]

    鑰?#28725;?#26440;?#37713;?#37928;勭粨鏋?#28103;?#37805;?#38171;?#37812;戜滑鍙?#37916;?#23011;忎釜?#22158;绋嬫墍?#39559;鐢?#37928;?#25652;?#37721;疯?#30028;劧閮?#37711;?#27996;?#37722;?#28051;?#37340;SequenceNumber瀹炰緥锛?#28003;嗗?#20903;滑骞舵病鏈?#37721;?#37922;熺浉浜?#39582;?#37813;?#37928;勬?#21613;喌锛岃?#37828;?#37722;勮嚜?#39559;鐢熺嫭绔?#37928;?#25652;?#37714;楀彿锛?#26473;?#37828;?#37733;?#28051;?#37812;戜滑閫?#26473;ThreadLocal涓?#23011;?#28051;?#37340;?#22158;绋?#37819;愪緵浜?#37719;曠嫭鐨勫壇鏈?#37510;?/p>

    Thread鍚屾鏈?#37714;?#37928;勬?#26055;緝

    ThreadLocal鍜岀嚎绋?#37722;屾鏈?#37714;剁浉姣?#37832;?#28000;涔?#28028;?#37716;?#37723;紵ThreadLocal鍜岀嚎绋?#37722;屾鏈?#37714;?#38318;?#37828;?#28051;?#27996;?#29785;喅澶氱嚎绋?#28051;浉鍚?#37721;?#38322;?#37928;勮闂?#37712;?#32464;?#38338;?#26864;?#37510;?/p>

    ?#28266;鍚屾鏈?#37714;?#28051;?#38171;岄?#26473;囧?#30789;薄鐨勯攣鏈?#37714;?#28103;?#29831;?#37722;?#28051;?#26882;闂?#37721;?#37832;?#28051;?#37340;?#22158;绋嬭闂?#37721;?#38322;?#37510;?#26473;欐椂璇?#37721;?#38322;?#37828;?#28598;氫釜?#22158;绋?#37711;?#27996;?#37928;?#38171;?#28003;?#37922;?#37722;屾鏈?#37714;?#29781;佹眰绋?#25652;忔?#24225;瘑鍦?#37714;?#37835;?#28000;涔堟椂鍊?#28725;?#37721;?#38322;?#26473;?#29723;?#29831;?#37712;?#38171;?#28000;涔堟椂鍊?#38343;瑕侀?#20344;畾鏌愪釜瀵硅薄锛?#28000;涔堟椂鍊欓噴鏀?#28725;硅薄閿佺?#22796;箒鏉?#37928;?#38338;?#26864;?#38171;?#32459;?#25652;?#29825;?#29825;?#37724;岀紪鍐?#38341;?#25652;浉瀵?#26440;?#28598;?#37510;?/p>

    鑰孴hreadLocal鍒欎粠鍙?#28051;?#37340;瑙?#25652;?#37833;?#29785;喅澶氱嚎绋?#37928;勫苟鍙戣闂?#37510;俆hreadLocal?#32048;涓?#23011;?#28051;?#37340;?#22158;绋?#37819;愪緵涓?#37340;?#23277;绔?#37928;?#37721;?#38322;?#37715;?#37832;?#38171;?#28000;庤岄?#26050;浜?#28598;氫釜?#22158;绋?#28725;规暟鎹?#37928;勮闂?#37712;?#32464;?#37510;?#37733;?#28051;?#23011;?#28051;?#37340;?#22158;绋?#38318;芥嫢鏈?#38007;繁鐨?#37721;?#38322;?#37715;?#37832;?#38171;?#28000;庤屼篃灏辨病鏈夊繀瑕?#28725;?#29831;?#37721;?#38322;?#26473;?#29723;?#37722;屾浜?#37510;俆hreadLocal鎻愪緵浜嗙嚎绋嬪?#22794;叏鐨?#37711;?#27996;?#28725;硅薄锛屽湪缂?#37712;?#28598;氱嚎绋?#28000;?#37934;佹椂锛?#37721;?#28000;妸?#31497;瀹夊叏鐨?#37721;?#38322;?#28751;佽杩汿hreadLocal銆?/p>

    鐢?#27996;嶵hreadLocal涓?#37721;?#28000;?#37816;?#37832;?#28000;?#28003;?#32491;诲瀷鐨?#28725;硅薄锛?#28003;?#37911;?#37832;JDK?#22669;鎻愪緵鐨刧et()杩?#37733;?#37928;?#37828;Object瀵硅薄锛?#38343;瑕?#23534;?#37714;?#32491;诲?#23341;浆?#23858;銆?#28003;咼DK 5.0閫?#26473;?#23049;涘瀷寰?#28610;?#37928;勮?#21893;浜?#26473;欎釜闂?#26864;?#38171;屽湪涓?#30078;绋?#25652;?#37734;扮畝鍖朤hreadLocal鐨?#28003;?#37922;?#38171;?#28000;?#37934;佹?#21613;崟 9 2灏?#28003;?#37922;?#27996;咼DK 5.0鏂?#37928;凾hreadLocal<T>鐗?#37832;?#37510;?/p>

    姒傛嫭璧?#37833;?#29831;?#38171;屽浜?#28598;氱嚎绋?#29863;勬簮鍏?#27996;?#37928;?#38338;?#26864;?#38171;?#37722;屾鏈?#37714;?#38322;?#37922;?#27996;?#8220;浠椂闂存崲绌?#38338;?#8221;鐨勬柟寮?#38171;岃孴hreadLocal閲?#37922;?#27996;?#8220;浠?#32460;?#38338;存崲?#26882;闂?#8221;鐨勬柟寮?#37510;?#37715;?#38000;?#28000;?#37819;愪緵涓浠?#37721;?#38322;?#38171;?#29825;笉鍚?#37928;勭嚎绋?#37818;?#38339;?#29825;?#38338;?#38171;岃?#37722;庤?#28051;?#23011;?#28051;?#37340;?#22158;绋?#38318;?#37819;愪緵浜?#28051;浠?#37721;?#38322;?#38171;屽洜姝?#37721;?#28000;?#37722;屾椂璁?#38338;?#38000;屼?#25485;笉褰卞搷銆?/p>

    Spring浣?#37922;ThreadLocal瑙喅?#22158;绋嬪?#22794;叏闂?#26864;?/p>

    鎴戜滑?#29025;閬撳湪涓鑸?#37807;呭喌涓?#38171;?#37721;?#37832;?#37827;犵姸鎬?#37928;凚ean鎵?#37721;?#28000;湪澶氱嚎绋?#37916;?#28583;?#28051;?#37711;?#27996;?#38171;屽湪Spring涓?#38171;?#32513;?#28598;?#38318;?#37714;Bean閮?#37721;?#28000;?#28601;?#37828;?#28051;簊ingleton浣?#37922;?#37737;?#37510;?#28751;?#37828;?#37733;?#28051;篠pring瀵?#28051;浜汢ean锛?#28641;RequestContextHolder銆乀ransactionSynchronizationManager銆丩ocaleContextHolder绛?#38171;?#28051;?#38344;炵嚎绋嬪?#22794;叏鐘?#37804;?#38322;?#37922;ThreadLocal杩?#29723;?#28598;勭悊锛?#29825;?#28729;冧滑涔?#37812;?#28051;虹嚎绋嬪?#22794;叏鐨勭姸鎬?#38171;屽洜涓?#37832;夌姸鎬?#37928;凚ean灏?#37721;?#28000;湪澶氱嚎绋?#28051;?#37711;?#27996;?#27996;?#37510;?/p>

    涓鑸?#37928;刉eb搴?#37922;?#37714;?#37714;?#28051;?#28766;?#37916;?#28766;?#37510;?#37832;?#37716;?#28766;傚拰鎸?#28052;呭眰涓変釜灞傛锛屽湪?#31497;鍚?#37928;?#28766;?#28051;?#32514;?#37712;?#28725;?#25652;?#37928;勯?#26440;?#38171;?#28051;?#28766;傞?#26473;?#37818;?#37721;?#37722;戜笂灞?#23534;鏀?#37716;熻兘?#30367;鐢?#37510;傚湪涓鑸?#37807;呭喌涓?#38171;?#28000;?#37818;?#37824;?#29831;锋?#20634;埌杩?#37733;?#37725;?#25652;旀墍缁?#26473;?#37928;勬墍鏈?#32459;?#25652;忚皟鐢?#38318;?#37722;屽?#28848;簬涓?#37340;?#22158;绋?#38171;?#28641;?#37733;?鈥??#22669;绀?#38171;?/p>

     

    鍥?鍚?#28051;?#22158;绋嬭閫?#28051;夊眰

    杩?#37837;蜂?#29362;氨鍙?#28000;?#37837;规嵁闇瑕?#38171;屽皢涓浜?#38344;炵嚎绋嬪?#22794;叏鐨?#37721;?#38322;?#28000;ThreadLocal瀛?#37824;?#38171;屽湪鍚?#28051;娆?#29831;锋?#20634;搷搴?#37928;勮皟鐢嚎绋?#28051;?#38171;屾墍鏈夊叧?#20168;鐨?#28725;硅薄寮?#37922;埌鐨?#38318;?#37828;?#37722;?#28051;?#37340;鍙?#38322;?#37510;?/p>

    涓嬮潰鐨?#28729;炰?#23341;兘澶?#28003;?#37916;癝pring瀵规湁鐘?#37804;丅ean鐨勬敼閫?#37804;濊矾锛?/p>

    浠?#37934;佹?#21613;崟3 TopicDao锛?#38344;炵嚎绋嬪?#22794;叏

    public class TopicDao {

    private Connection conn;鈶?#28051;?#37340;闈炵嚎绋嬪?#22794;叏鐨?#37721;?#38322;?/p>

    public void addTopic(){

    Statement stat = conn.createStatement();鈶?#23534;?#37922;?#38344;炵嚎绋嬪?#22794;叏鍙?#38322;?/p>

    }

    }

    鐢?#27996;?#37430;?#28598;?#37928;刢onn鏄?#37812;?#37723;?#37721;?#38322;?#38171;屽洜涓addTopic()鏂规硶鏄?#38344;炵嚎绋嬪?#22794;叏鐨?#38171;屽繀椤诲湪浣?#37922;椂鍒涘缓涓?#37340;鏂TopicDao瀹炰緥锛?#38344;singleton锛?#37510;?#28051;嬮潰浣?#37922;ThreadLocal瀵筩onn杩欎釜闈炵嚎绋嬪?#22794;叏鐨?#8220;鐘?#37804;?#8221;杩?#29723;屾敼閫?#38171;?/p>

    浠?#37934;佹?#21613;崟4 TopicDao锛氱嚎绋嬪?#22794;叏

    import java.sql.Connection;

    import java.sql.Statement;

    public class TopicDao {

    鈶?#28003;?#37922;ThreadLocal淇?#28699;Connection鍙?#38322;?/p>

    private static ThreadLocal<Connection> connThreadLocal = new ThreadLocal<Connection>();

    public static Connection getConnection(){

    鈶?#28641;?#37835;渃onnThreadLocal?#30149;鏈?#37832;嚎绋?#28725;?#25652;?#37928;凜onnection鍒涘缓涓?#37340;鏂?#37928;凜onnection锛?/p>

    骞?#28751;?#37711;?#28103;?#28699;樺埌?#22158;绋?#37832;?#37734;?#37721;?#38322;?#28051;?#37510;?/p>

    if (connThreadLocal.get() == null) {

    Connection conn = ConnectionManager.getConnection();

    connThreadLocal.set(conn);

    return conn;

    }else{

    return connThreadLocal.get();?#25023;鐩?#37818;?#26473;?#37733;炵嚎绋?#37832;?#37734;?#37721;?#38322;?/p>

    }

    }

    public void addTopic() {

    鈶?#28000;嶵hreadLocal涓?#38014;?#37721;栫嚎绋?#28725;?#25652;?#37928;凜onnection

    Statement stat = getConnection().createStatement();

    }

    }

    ?#31497;鍚?#37928;勭嚎绋嬪湪浣?#37922;TopicDao?#26882;锛屽厛鍒?#37826;璫onnThreadLocal.get()鏄惁鏄痭ull锛?#28641;?#37835;?#37828;痭ull锛?#37714;?#29831;?#37828;庡?#25779;墠?#22158;绋嬭繕?#30149;鏈夊搴?#37928;凜onnection瀵硅薄锛?#26473;欐椂鍒涘缓涓?#37340;Connection瀵硅薄骞舵?#35826;?#29362;埌鏈?#37734;扮嚎绋?#37721;?#38322;?#28051;?#38171;?#28641;?#37835;滀笉涓簄ull锛?#37714;?#29831;?#37828;庡?#25779;墠鐨勭嚎绋嬪凡缁忔嫢鏈?#27996;咰onnection瀵硅薄锛?#37929;?#37818;?#28003;?#37922;?#28751;?#37721;?#28000;?#27996;?#37510;?#26473;?#37837;?#38171;屽氨淇?#29831;?#27996;嗕笉鍚?#37928;勭嚎绋?#28003;?#37922;嚎绋嬬浉鍏?#37928;凜onnection锛岃屼笉?#32048;浣?#37922;?#37711;?#28729;冪嚎绋?#37928;凜onnection銆?#37733;?#23005;?#38171;?#26473;欎釜TopicDao灏?#37721;?#28000;?#37707;氬埌singleton鍏?#27996;?#27996;?#37510;?/p>

    褰撶劧锛?#26473;欎釜渚?#28699;?#37832;?#38892;?#23536;堢绯?#38171;屽皢Connection鐨凾hreadLocal鐩?#37818;?#37824;惧湪DAO鍙兘鍋氬埌鏈珼AO鐨?#28598;氫釜鏂规硶鍏?#27996;獵onnection?#26882;?#31497;鍙?#37922;熺嚎绋嬪?#22794;叏闂?#26864;?#38171;?#28003;?#37827;犳硶?#25328;鍏?#28729;僁AO鍏?#37922;?#37722;?#28051;?#37340;Connection锛?#29781;佸?#27692;埌鍚?#28051;浜?#37716;?#28598;欴AO鍏?#27996;?#37722;?#28051;Connection锛屽繀椤诲湪涓?#37340;鍏?#37722;?#37928;?#28598;?#38318;?#32491;?#28003;?#37922;ThreadLocal淇?#28699;Connection銆?/p>

    灏忕粨

    ThreadLocal鏄?#29785;喅?#22158;绋嬪?#22794;叏闂?#26864;?#28051;?#37340;寰?#28610;?#37928;勬濊矾锛屽畠閫?#26473;?#28051;?#23011;忎釜?#22158;绋?#37819;愪緵涓?#37340;?#23277;绔?#37928;?#37721;?#38322;?#37715;?#37832;?#29785;喅浜?#37721;?#38322;?#39582;?#37721;戣闂?#37928;?#37712;?#32464;?#38338;?#26864;?#37510;傚湪寰?#28598;?#37807;呭喌涓?#38171;孴hreadLocal姣旂洿鎺?#28003;?#37922;synchronized鍚屾鏈?#37714;?#29785;喅?#22158;绋嬪?#22794;叏闂?#26864;?#37831;寸畝鍗?#38171;?#37831;?#37826;?#28186;?#38171;?#28051;旂粨鏋?#32459;?#25652;忔嫢鏈?#37831;撮珮鐨勫苟鍙戞?#37510;?/p>

     

    鏈?#37826;?#37833;?#38007;狢SDN鍗?#28729;?#38171;岃浆杞?#29831;?#37837;?#37828;?#37713;?#28598;?#38171;歨ttp://blog.csdn.net/qjyong/archive/2008/03/08/2158097.aspx



    ]]>
    ownerhttp://www.67529968.com/lingy/archive/2009/07/24/288258.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Fri, 24 Jul 2009 12:13:00 GMThttp://www.67529968.com/lingy/archive/2009/07/24/288258.html

    ]]>
    ilevelhttp://www.67529968.com/lingy/archive/2009/07/23/287998.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Thu, 23 Jul 2009 03:51:00 GMThttp://www.67529968.com/lingy/archive/2009/07/23/287998.html
     
     
     
     


    ]]>ilevelhttp://www.67529968.com/lingy/archive/2009/07/23/287997.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Thu, 23 Jul 2009 03:51:00 GMThttp://www.67529968.com/lingy/archive/2009/07/23/287997.html
     
     
     
     


    ]]>EXECUTE IMMEDIATE鐢硶灏?#29785;?http://www.67529968.com/lingy/archive/2009/07/16/287019.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Thu, 16 Jul 2009 11:42:00 GMThttp://www.67529968.com/lingy/archive/2009/07/16/287019.html 瀹?#29785;?#37835;?#39582;堕涓?#37813;?#29723;屽姩鎬?#37928;凷QL璇?#37721;?#37812;?#38344;?#26473;?#29723;屾椂鍒涘缓鐨PL/SQL鍧??#23017;鎬?#37714;涘?#21700;拰鎵?#29723;孲QL璇?#37721;?#37804;兘瓒呭墠锛孍XECUTE IMMEDIATE鐨勭洰鏍囧湪浜?#37713;?#28751;?#28028;?#28051;?#29840;?#37922;?#39582;惰幏寰?#26440;冮珮鐨勬兘锛?#26440;?#28052;?#28000;?#37715;?#28729;冪浉褰撳鏄撶紪鐮?灏界DBMS_SQL浠嶇劧鍙?#37922;?#38171;?#28003;?#37828;?#37818;?#38013;?#28003;?#37922;EXECUTE IMMEDIATE,鍥?#28051;?#28729;冭幏鐨勬敹鐩婂湪鍖?#28052;?#28051;?#37510;?


    -- 浣?#37922;?#37814;宸?br />

    1. EXECUTE IMMEDIATE灏嗕笉?#32048;鎻愪氦涓?#37340;DML浜?#37716;?#37813;?#29723;?#38171;屽?#26055;鏄?#23534;?#37819;愪氦
    濡?#37835;滈?#26473;EXECUTE IMMEDIATE澶勭悊DML鍛戒护锛?br /> 閭?#28052;堝湪瀹?#37812;?#28000;?#37715;?#38343;瑕?#37828;?#23534;?#37819;愪氦鎴?#38000;?#28003;?#28051;篍XECUTE IMMEDIATE鑷繁鐨?#28051;閮?#37714;?
    濡?#37835;滈?#26473;EXECUTE IMMEDIATE澶勭悊DDL鍛戒护,瀹?#37819;愪氦?#22669;鏈?#28000;?#37715;嶆敼鍙?#37928;勬暟鎹?br />

    2. ?#31497;鏀?#37816;?#26473;?#37733;?#28598;?#29723;?#37928;勬煡璇?杩欑浜?#27996;?#28751;?#37922;?#28051;存椂琛?#37833;?#28699;樺偍璁?#35120;?鍙傜収渚?#28699;?#28641;?#28051;?鎴?#38000;?#37922;REF cursors.


    3. 褰?#37813;?#29723;孲QL璇?#37721;椂锛屼笉瑕?#37922;?#37714;?#37721;?#38171;屽綋鎵?#29723;孭L/SQL鍧楁椂锛屽湪鍏?#28751;?#38318;?#37922;?#37714;?#37721;?


    4. ?#28266;Oracle鎵?#37712;?#28051;?#38171;?#37832;?#29831;?#32513;?#29781;?#37929;?#26473;欎簺鍔熻兘銆?br /> 涓嬮潰鐨勪緥瀛?#28766;曠浜嗘墍鏈?#37922;埌Execute immediate鐨?#37721;兘鏂归潰.甯?#37832;涜兘缁欎綘甯?#37833;?#37826;?#28186;?


    5. 瀵?#27996;嶧orms寮鍙戣?褰撳湪PL/SQL 8.0.6.3.鐗?#37832;?#28051;?#38171;Forms 6i?#31497;?#20824;浣?#37922;?#23005;?#37716;熻兘.


    EXECUTE IMMEDIATE -- 鐢硶渚?#28699;?br />

    1. ?#28266;PL/SQL杩?#29723;孌DL璇?#37721;?br />

    begin
       execute immediate 'set role all';
    end;


    2. 缁欏姩鎬?#29831;?#37721;?#28028;?#37706;?USING 瀛?#37721;?


    declare
       l_depnam varchar2(20) := 'testing';
       l_loc     varchar2(10) := 'Dubai';
       begin
       execute immediate 'insert into dept values   (:1, :2, :3)'
         using 50, l_depnam, l_loc;
       commit;
    end;


    3. 浠庡姩鎬?#29831;?#37721;?#22955;?#20648;鍊?INTO瀛?#37721;?


    declare
       l_cnt     varchar2(20);
    begin
       execute immediate 'select count(1) from emp'
         into l_cnt;
       dbms_output.put_line(l_cnt);
    end;


    4. ?#23017;鎬佽皟鐢?#28186;?#32459;?渚?#32459;?#28051;?#37922;埌鐨?#32513;戝畾鍙?#38322;?#37721;傛暟蹇?#26916;?#37816;囧畾鍙傛暟绫诲瀷.
    ?#31912;璁?#28051;篒N绫诲瀷,鍏?#28729;?#32491;诲?#23338;繀椤?#37828;?#23534;?#37816;囧畾


    declare
       l_routin    varchar2(100) := 'gen2161.get_rowcnt';
       l_tblnam    varchar2(20) := 'emp';
       l_cnt       number;
       l_status    varchar2(200);
    begin
       execute immediate 'begin ' || l_routin || '(:2, :3, :4); end;'
         using in l_tblnam, out l_cnt, in out l_status;

       if l_status != 'OK' then
          dbms_output.put_line('error');
       end if;
    end;


    5. 灏?#26473;?#37733;?#37706;?#28028;?#38315;掑埌PL/SQL璁?#35120;?#32491;诲瀷;鍚?#37837;蜂篃鍙?#37922;?rowtype鍙?#38322;?br />

    declare
       type empdtlrec is record (empno   number(4),
                                ename   varchar2(20),
                                deptno   number(2));
       empdtl empdtlrec;
    begin
       execute immediate 'select empno, ename, deptno ' ||
                        'from emp where empno = 7934'
         into empdtl;
    end;


    6. 浼?#38315;?#39582;舵?#20648;鍊?INTO瀛?#37721;?#37922;湪USING瀛?#37721;?#37715;?br />

    declare
       l_dept     pls_integer := 20;
       l_nam      varchar2(20);
       l_loc      varchar2(20);
    begin
       execute immediate 'select dname, loc from dept where deptno = :1'
         into l_nam, l_loc
         using l_dept ;
    end;


    7. 澶?#29723;屾煡璇?#38315;?#26916;?瀵规閫?#26916;?#37922;insert璇?#37721;?#28617;?#37711;?#28051;存椂琛?#38171;?br /> 鐢?#28051;存椂琛?#26473;?#29723;?#26473;?#28051;姝?#37928;?#28598;勭悊,涔?#37721;?#28000;?#37922;REF cursors绾?#23005;?#23005;?#32514;烘.

    declare
       l_sal    pls_integer := 2000;
    begin
       execute immediate 'insert into temp(empno, ename) ' ||
                        '           select empno, ename from emp ' ||
                        '           where   sal > :1'
         using l_sal;
       commit;
    end;


            瀵?#27996;?#28598;勭?#21975;姩鎬?#29831;?#37721;?EXECUTE IMMEDIATE 姣?#28000;?#37715;?#37721;兘鐢埌鐨?#37831;?#28729;?#37828;撳苟涓?#37831;撮珮鏁?
    褰撴?#24531;浘鎵?#29723;屽姩鎬?#29831;?#37721;椂锛岄?#35120;撳湴澶勭悊寮?#29999;?#37831;?#37716;?#38322;?#29781;?搴旇鍏?#23049;?#27996;庢?#26337;?#38155;墍鏈?#37721;兘鐨?#23534;?#29999;?
    鎴?#37828;?#37827;犺亰鐨勪汉锛屾墍浠?#37707;?#37827;犺亰鐨勪簨鎯?#37510;?/em>


    ]]>
    浣?#37922;?TRUNCATE TABLE 鍒犻櫎?#22669;鏈?#29723;?/title><link>http://www.67529968.com/lingy/archive/2009/07/16/287018.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Thu, 16 Jul 2009 11:41:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2009/07/16/287018.html</guid><description><![CDATA[<div class="topic"> <div class="majorTitle">SQL Server 2008 ?#20168;鏈?#28051;?#28052;?#38171;?009 骞?5 鏈?#38171;?!----></div> <div class="title">浣?#37922;?TRUNCATE TABLE 鍒犻櫎?#22669;鏈?#29723;?!----></div> <!--content type: DocStudio. Transform: devdiv2mtps.xslt.--> <div id="mainSection"> <div id="mainBody"> <p><!----></p> <p>?#23266;瑕?#37714;犻櫎琛?#28051;?#37928;勬墍鏈?#29723;?#38171;?#37714;?TRUNCATE TABLE 璇?#37721;?#37828;?#28051;绉?#36423;?#38315;?#37510;?#37832;?#37825;?#37928;勬?#35268;硶銆俆RUNCATE TABLE 涓庝笉鍚?WHERE 瀛?#37721;?#37928;?DELETE 璇?#37721;?#32491;?#28028;?#37510;?#28003;?#37828;?#38171;孴RUNCATE TABLE 閫?#25652;?#37831;?#36423;?#38171;屽苟涓?#28003;?#37922;?#37831;?#28751;?#37928;勭?#33636;粺璧勬簮?#25328;浜?#37716;?#37827;織璧勬簮銆?/p> <p>涓?DELETE 璇?#37721;浉姣?#38171;孴RUNCATE TABLE 鍏?#37832;?#28000;?#28051;?#28028;?#37904;?#38171;?/p> <ul> <li>?#22669;鐢?#37928;勪簨鍔?#37827;織绌?#38338;?#26440;?#28751;?#37510;?br /> DELETE 璇?#37721;?#23011;?#23046;?#37714;犻櫎涓琛?#38171;屽?#36346;湪浜?#37716;?#37827;織涓?#28051;烘墍鍒犻櫎鐨勬瘡琛?#29825;?#35120;?#28051;?#37340;椤?#37510;俆RUNCATE TABLE 閫?#26473;囬噴鏀?#37922;?#27996;?#28699;樺偍琛暟鎹?#37928;勬暟鎹?#26916;?#37833;?#37714;犻櫎?#26271;鎹?#38171;屽苟涓斿湪浜?#37716;?#37827;織涓?#37721;?#29825;?#35120;?#26916;甸噴鏀?#37510;?br /> <li>浣?#37922;?#37928;勯?#20352;?#29999;歌緝灏?#37510;?br /> 褰?#28003;?#37922;?#29723;岄攣鎵?#29723;?DELETE 璇?#37721;椂锛屽皢閿佸畾琛?#28051;?#37722;勮浠?#28186;?#37714;犻櫎銆俆RUNCATE TABLE 濮?#32513;堥?#20344;畾琛拰椤?#38171;岃屼笉鏄?#38335;佸畾鍚勮銆?br /> <li>濡?#37827;?#28186;?#28598;?#38171;屽湪琛?#28051;笉?#32048;?#26240;鏈?#28000;?#28003;?#26916;?#37510;?br /> 鎵?#29723;?DELETE 璇?#37721;?#37722;?#38171;?#29723;?#28000;嶄細鍖呭惈绌?#26916;?#37510;備緥濡?#38171;屽繀椤?#38007;冲?#25116;娇鐢?#28051;?#37340;鎺?#28000;?(LCK_M_X) 琛?#38335;?#38171;?#37813;嶈兘?#22132;鏀惧爢涓?#37928;勭琛?#37510;?#28641;?#37835;?#37813;?#29723;?#37714;犻櫎鎿?#28003;滄椂?#30149;鏈?#28003;?#37922;?#29723;?#38335;?#38171;?#29723;?#38171;堝爢锛?#28051;?#28751;嗗?#21613;惈璁?#28598;氱椤?#37510;?#28725;?#27996;庣储寮?#38171;?#37714;犻櫎鎿?#28003;滀細鐣欎笅涓浜涚椤?#38171;屽?#30028;杩欎簺椤典細閫?#26473;囧悗鍙版?#21620;櫎杩涚?#23341;繀閫熼噴鏀?#37510;?br /> </li> </ul> <p>涓?DELETE 璇?#37721;浉鍚?#38171;?#28003;?#37922;?TRUNCATE TABLE 娓呯鐨勮鐨勫畾涔?#28051;庡?#21057;储寮曞拰鍏?#28000;栧叧?#20168;瀵硅薄涓璧蜂?#28616;暀?#28266;?#26271;鎹?#25652;?#28051;?#37510;?#28641;?#37835;?#29723;?#28051;?#37718;呭惈鏍?#29831;?#37714;?#38171;?#29831;?#37714;?#37928;勮?#26271;鍣?#28751;?#38322;嶇疆涓?#29831;?#37714;楀畾涔?#37928;勭瀛?#37706;?#37510;?#28641;?#37835;?#37832;畾涔?#32457;?#28699;?#38171;?#37714;欎娇鐢?#27035;樿鍊?1銆傝嫢瑕?#28103;濈暀鏍?#29831;?#29825;暟鍣?#38171;?#29831;蜂娇鐢?DELETE銆?/p> <div id="ctl00_MTContentSelector1_mainContentContainer_cpe28768" class="MTPS_CollapsibleRegion"> <div id="ctl00_MTContentSelector1_mainContentContainer_cpe28768_h" class="CollapseRegionLink" onclick="applyClick('ctl00_MTContentSelector1_mainContentContainer_cpe28768');"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; vertical-align: middle; border-left-width: 0px" id="ctl00_MTContentSelector1_mainContentContainer_cpe28768_i" class="LibC_o" src="http://i.technet.microsoft.com/Global/Images/clear.gif" alt="" /> 鎴?#37826;?#28598;?#37736;嬭 </div> <div style="display: block" id="ctl00_MTContentSelector1_mainContentContainer_cpe28768_c" class="MTPS_CollapsibleSection"><a id="sectionToggle0"><!----></a> <p>Microsoft SQL Server 寮曞叆涓绉?#37716;熻兘锛屾鍔熻兘鍙?#37714;犻櫎鎴?#37812;?#37826;?#29906;?#26473;?128 ?#37340;鍖?#37928;勮锛岃?#37827;?#38343;鍚屾椂淇濈暀闇瑕?#37714;犻櫎鐨勬墍鏈夊尯鐨勯攣銆?#37832;夊叧璇?#32513;?#28103;?#37805;?#38171;?#29831;?#37721;?#38339;?a id="ctl00_MTContentSelector1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_cpe28768_c|ctl00_MTContentSelector1_mainContentContainer_ctl04',this);" href="http://technet.microsoft.com/zh-cn/library/ms177495.aspx">鍒犻櫎骞?#38322;?#37826;?#37922;?#37812;?#28598;瀷瀵硅薄</a>銆?/p> </div> </div> <div id="ctl00_MTContentSelector1_mainContentContainer_cpe28769" class="MTPS_CollapsibleRegion"> <div id="ctl00_MTContentSelector1_mainContentContainer_cpe28769_h" class="CollapseRegionLink" onclick="applyClick('ctl00_MTContentSelector1_mainContentContainer_cpe28769');"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; vertical-align: middle; border-left-width: 0px" id="ctl00_MTContentSelector1_mainContentContainer_cpe28769_i" class="LibC_o" src="http://i.technet.microsoft.com/Global/Images/clear.gif" alt="" /> 绀?#28186;?</div> <div style="display: block" id="ctl00_MTContentSelector1_mainContentContainer_cpe28769_c" class="MTPS_CollapsibleSection"><a id="sectionToggle1"><!----></a> <p>涓嬮潰鐨勭渚?#37714;犻櫎 <code>JobCandidate</code> 琛?#28051;?#37928;勬墍鏈夋暟鎹?#37510;傚湪 <code>TRUNCATE TABLE</code> 璇?#37721;?#28052;嬪墠?#25328;涔?#37722;?#28003;?#37922;?<code>SELECT</code> 璇?#37721;?#37833;?#23011;旇?#20906;粨鏋?#37510;?/p> <div id="ctl00_MTContentSelector1_mainContentContainer_ctl08_other"> <div class="CodeSnippetTitleBar"> <div class="CodeDisplayLanguage"></div> <div class="CopyCodeButton"><a class="copyCode" title="澶?#37714;?#28000;?#37934;? href="javascript:CopyCode('ctl00_MTContentSelector1_mainContentContainer_ctl08other');"> <div class="LibC_copy_off" align="center" border="0" height="9px" width="auto"></div> 澶?#37714;?#28000;?#37934;?/a></div> </div> <div dir="ltr"> <pre style="word-wrap: break-word; word-break: break-all" id="ctl00_MTContentSelector1_mainContentContainer_ctl08other" class="libCScode" space="preserve">USE AdventureWorks; GO SELECT COUNT(*) AS BeforeTruncateCount FROM HumanResources.JobCandidate; GO TRUNCATE TABLE HumanResources.JobCandidate; GO SELECT COUNT(*) AS AfterTruncateCount FROM HumanResources.JobCandidate; GO </pre> </div> </div> </div> </div> <div id="ctl00_MTContentSelector1_mainContentContainer_cpe28770" class="MTPS_CollapsibleRegion"> <div id="ctl00_MTContentSelector1_mainContentContainer_cpe28770_h" class="CollapseRegionLink" onclick="applyClick('ctl00_MTContentSelector1_mainContentContainer_cpe28770');"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; vertical-align: middle; border-left-width: 0px" id="ctl00_MTContentSelector1_mainContentContainer_cpe28770_i" class="LibC_o" src="http://i.technet.microsoft.com/Global/Images/clear.gif" alt="" /> 璇?#37721;?#38339;?</div> <div style="display: block" id="ctl00_MTContentSelector1_mainContentContainer_cpe28770_c" class="MTPS_CollapsibleSection"><a id="seeAlsoToggle"><!----></a> <h4 class="subHeading">姒傚康</h4> <a id="ctl00_MTContentSelector1_mainContentContainer_ctl17" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_cpe28770_c|ctl00_MTContentSelector1_mainContentContainer_ctl17',this);" href="http://technet.microsoft.com/zh-cn/library/ms189245.aspx">浣?#37922;?DELETE 鍒犻櫎琛?/a><br /> <a id="ctl00_MTContentSelector1_mainContentContainer_ctl18" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_cpe28770_c|ctl00_MTContentSelector1_mainContentContainer_ctl18',this);" href="http://technet.microsoft.com/zh-cn/library/ms189634.aspx">鍒犻櫎?#31912;鏋滈泦涓?#37928;勮</a><br /> <a id="ctl00_MTContentSelector1_mainContentContainer_ctl19" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_cpe28770_c|ctl00_MTContentSelector1_mainContentContainer_ctl19',this);" href="http://technet.microsoft.com/zh-cn/library/ms175486.aspx">浣?#37922;?TOP 闄?#37714;?#37714;犻櫎鐨勮</a><br /> <h4 class="subHeading">鍏?#28000;?#29863;勬簮</h4> <a id="ctl00_MTContentSelector1_mainContentContainer_ctl20" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_cpe28770_c|ctl00_MTContentSelector1_mainContentContainer_ctl20',this);" href="http://technet.microsoft.com/zh-cn/library/ms173790.aspx">DROP TABLE (Transact-SQL)</a><br /> <a id="ctl00_MTContentSelector1_mainContentContainer_ctl21" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_cpe28770_c|ctl00_MTContentSelector1_mainContentContainer_ctl21',this);" href="http://technet.microsoft.com/zh-cn/library/ms177570.aspx">TRUNCATE TABLE (Transact-SQL)</a><br /> <br /> <h4 class="subHeading">甯?#37716;拰淇?#37805;?</h4> <a id="ctl00_MTContentSelector1_mainContentContainer_ctl22" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_cpe28770_c|ctl00_MTContentSelector1_mainContentContainer_ctl22',this);" href="http://technet.microsoft.com/zh-cn/library/ms166016.aspx">鑾?#37721;?SQL Server 2008 甯?#37716;?</a></div> </div> </div> </div> </div> <img src ="http://www.67529968.com/lingy/aggbug/287018.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2009-07-16 19:41 <a href="http://www.67529968.com/lingy/archive/2009/07/16/287018.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>涓?#37340;绠鍗?#37928;勯?#26440;?#28598;?#28000;界?#26667;暐瀛範 http://www.67529968.com/lingy/archive/2009/07/10/286287.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Fri, 10 Jul 2009 08:58:00 GMThttp://www.67529968.com/lingy/archive/2009/07/10/286287.html涓?#37340;绠鍗?#37928;勯?#26440;?#28598;?#28000;界?#26667;暐瀛範
    闇?#30512;锛?br /> 姣?#28598;?9:00澶?#28000;?#28051;娆?#28051;?#37716;?#37922;?#37812;?br /> 姣忎釜澶?#28000;?#37832;澶?#28103;濈暀7澶?br /> 姣忎釜澶?#28000;?#37922;?#37827;?#37832;?#28003;?#28051;?#28598;?#28000;?#37826;?#28000;?#37928;?#37722;嶇

    [root@localhost opt]# cat /home/autoBackup/ora_env
    export ORACLE_BASE=/opt/oracle
    export ORACLE_HOME=/opt/oracle/product/10.2.0
    export ORACLE_SID=STAPLES
    export ORACLE_TERM=xterm
    #export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
    export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    export PATH=$PATH:$ORACLE_HOME/bin

    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/jlib
    export JAVA_HOME=$ORACLE_HOME/jdk
    export ORA_NLS10=$ORACLE_HOME/nls/data
    export LC_CTYPE=en_US.UTF-8

    [root@localhost opt]# cat /opt/backup_exp.sh
    #!/bin/sh
    #CREATOR锛歞aimin
    #function锛歜ackup database with expdp
    #usage锛歝rontab on linux
    #last modify锛歵uolei 2007-08-29 create
    #set environment variable
    . /home/autoBackup/ora_env  #璁?#32515;exp鐨?#37916;?#28583;?#37721;?#38322;?br /> #寮濮?#28598;?#28000;?#38171;屽?#22247;畾?#27952;褰backupPath宸?#32513;?#37714;涘缓锛屽苟涓攂ackupPath=/opt/oracle/backup
    backupPath='/opt/oracle/backup/'
    FILE=`date +%Y%m%d`'.dmp'
    LOGFILE=`date +%Y%m%d`'.log'
    exp daimin/daimin@STAPLES file=$backupPath$FILE.dmp log=$backupPath$LOGFILE

    #鍒犻櫎浠?#37715;?#26473;?#37832;?#37928;?#28598;?#28000;?br /> find /opt/oracle/backup/* -name "*.dmp" -mtime +4 -exec rm {} \;

     

    [root@localhost etc]# crontab -e
    0 19 * * * /opt/backup_exp.sh > /opt/oracle/backup/logs/backup_exp.log 2>&1
    ~
    "crontab.XXXXmfkudb" 1L, 76C written
    crontab: installing new crontab
    [root@localhost etc]# crontab -l
    0 19 * * * /opt/backup_exp.sh > /opt/oracle/backup/logs/backup_exp.log 2>&1

    娉剰锛?br /> 1銆?opt/backup_exp.sh闇瑕?#37711;?#37832;?#37721;?#37813;?#29723;?#37833;?#38340;?#38171;?#37813;?#37721;?#28000;?#29722;玶oot鐢?#37812;?#37813;?#29723;?br /> [root@localhost backup]# chmod +x /opt/backup_exp.sh
    ?#24769;鍒欎細鍑?#37916;?bin/sh: /opt/backup_exp.sh: Permission denied?#25930;璇?br /> 2銆?#38343;瑕佸湪鑴?#37832;?#37928;?#32471;?#28051;琛屽姞#!/bin/sh
    ?#24769;鍒欎細鍑?#37916;?bin/sh: /opt/backup_exp.sh: cannot execute binary file?#25930;璇?br /> 3銆?#23049;?#37808;忓湪鎵?#29723;宔xp鍛戒护涔嬪墠锛?#38343;瑕?#29825;?#32515;?#37916;?#28583;?#37721;?#38322;?#38171;屾墍浠湪閫?#26440;?#28598;?#28000;借剼鏈?#28051;?#37813;?#29723;屼簡. /home/autoBackup/ora_env 鍛戒护;


    鍙?#38000;?#32515;戦锛?br /> http://blog.csdn.net/wzy0623/archive/2008/10/31/3193150.aspx
    http://www.linuxsir.org/main/?q=node/209


    鏈?#37826;?#37833;?#38007;狢SDN鍗?#28729;?#38171;岃浆杞?#29831;?#37837;?#37828;?#37713;?#28598;?#38171;歨ttp://blog.csdn.net/daimin1983/archive/2008/12/13/3511380.aspx



    ]]>
    Linux绯荤粺鍒?#37922;Crontab鍛戒护瀹?#37916;板畾?#26882;閲?#37722;?/title><link>http://www.67529968.com/lingy/archive/2009/07/10/286193.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Fri, 10 Jul 2009 03:01:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2009/07/10/286193.html</guid><description><![CDATA[銆浣?#38000;?#38171;歴ixth <p>銆銆Crontab鏄?#28051;?#37340;寰?#37826;?#28186;?#37928;勫湪unix/linux绯荤粺涓婂畾?#26882;(寰?#37916;?鎵?#29723;?#37836;愪釜浠诲姟鐨勭搴?</p> <p>銆銆浣?#37922;cron鏈?#37716;?#38171;?#37922;?service crond status ?#29025;?#28229; cron鏈?#37716;?#37912;?#37804;?#38171;?#28641;?#37835;滄病鏈?#37722;姩鍒?service crond start鍚姩瀹?#38171;?</p> <p>銆銆cron鏈?#37716;?#37828;?#28051;?#37340;?#30078;?#26882;鎵?#29723;?#37928;勬湇鍔?#38171;?#37721;?#28000;?#38315;?#26473;crontab 鍛戒护娣诲姞鎴?#38000;呯紪杈戦渶瑕佸畾?#26882;鎵?#29723;?#37928;?#28000;诲姟锛?</p> <p>銆銆crontab -u //璁惧畾鏌愪釜鐢?#37812;?#37928;刢ron鏈?#37716;?#38171;?#28051;鑸瑀oot鐢?#37812;峰湪鎵?#29723;?#26473;欎釜鍛戒护鐨勬椂鍊?#38343;瑕?#23005;?#37721;傛暟 </p> <p>銆銆crontab -l //鍒楀嚭鏌愪釜鐢?#37812;cron鏈?#37716;?#37928;?#29831;?#32513;?#37712;呭 </p> <p>銆銆crontab -r //鍒犻櫎?#30149;?#37340;鐢?#37812;?#37928;刢ron鏈?#37716;?</p> <p>銆銆crontab -e //缂?#26440;戞?#24874;釜鐢?#37812;?#37928;刢ron鏈?#37716;?</p> <p>銆銆姣?#28641;?#29831;磖oot?#29025;鐪嬭嚜?#32321;鐨刢ron璁?#32515;?#38171;歝rontab -u root -l </p> <p>銆銆鍐?#28186;?#28641;?#38171;宺oot鎯冲?#29371;櫎fred鐨刢ron璁?#32515;?#38171;歝rontab -u fred -r </p> <p>銆銆?#28266;缂?#26440;慶ron鏈?#37716;椂锛岀紪杈?#37928;?#37712;呭?#35268;湁涓浜?#37837;?#23534;?#37724;岀害?#30078;锛?#26440;撳叆锛歝rontab -u root -e </p> <p>銆銆杩涘叆vi缂?#26440;戞寮?#38171;岀紪杈?#37928;?#37712;呭涓?#30078;瑕?#32471;?#37722;?#28051;嬮潰鐨勬牸寮?#38171;?/1 * * * * ls >> /tmp/ls.txt </p> <p>銆銆缂?#26440;?etc/crontab鏂?#28000;?#38171;屽湪鏈?#28751;?#37716;?#28051;?#28051;琛?#38171;?30 5 * * * root init 6 杩?#37837;峰?#21342;皢绯荤粺閰嶇疆涓?#27996;?#23011;?#28598;?#37827;?#28051;?鐐?0鑷姩閲?#37826;?#37722;姩銆?</p> <p>銆銆闇瑕佸皢crond璁?#32515;?#28051;虹?#33636;粺鍚姩鍚庤嚜?#23017;鍚姩鐨勬湇鍔?#38171;?#37721;?#28000;湪/etc/rc.d/rc.local 涓?#38171;屽湪鏈?#28751;?#37716;?#28051;?</p> <p>銆銆service crond start </p> <p>銆銆濡?#37835;?#26473;?#38343;瑕佸湪绯荤粺鍚姩鍗?#37716;?#26462;?#37711;?#28000;?#37832;?#37716;?#38171;?#37721;?#28000;?#32513;?#32513;?#37716;?#28051;?#37711;?#28000;?#37832;?#37716;?#37928;?#37722;姩鍛戒护銆?</p> <p>銆銆姣?#28641;?#38171;?service mysqld start </p> <p>銆銆鍩?#37832;?#37922;硶: </p> <p>銆銆1. crontab -l </p> <p>銆銆鍒楀嚭褰撳墠鐨刢rontab浠诲姟 </p> <p>銆銆2. crontab -d </p> <p>銆銆鍒犻櫎褰撳墠鐨刢rontab浠诲姟 </p> <p>銆銆3. crontab -e (solaris5.8涓婇潰鏄?crontab -r) </p> <p>銆銆缂?#26440;戜竴?#37340;crontab浠诲姟,ctrl_D?#31912;鏉?</p> <p>銆銆4. crontab filename </p> <p>銆銆浠filename鍋?#28051;篶rontab鐨?#28000;诲姟鍒?#29723;?#37826;?#28000;?#39582;惰?#34249;叆 </p> <p>銆銆crontab file鐨勬牸寮? </p> <p>銆銆crontab 鏂?#28000;?#28051;?#37928;勮鐢?6 ?#37340;瀛?#23048;?#32513;勬垚锛屼笉鍚?#28699;?#23048;?#38338;?#37922;?#32460;?#37837;?#37812;?tab ?#25965;鍒嗛殧銆?#37715;?5 ?#37340;瀛?#23048;?#37816;囧畾鍛戒护瑕?#26473;?#29723;?#37928;勬椂闂?</p> <p>銆銆鍒嗛挓 (0-59) </p> <p>銆銆灏忔椂 (0-23) </p> <p>銆銆鏃?#37832;?(1-31) </p> <p>銆銆鏈?#28000;?(1-12) </p> <p>銆銆鏄?#37832;?#37713;?0-6锛?#37711;?#28051;?0 浠?#29723;?#37828;?#37832;?#37827;? </p> <p>銆銆绗?6 ?#37340;瀛?#23048;?#37828;?#28051;?#37340;瑕佸湪閫?#35120;撴椂闂存墽琛?#37928;?#28699;?#32471;?#28051;?</p> <p>銆銆渚?#28699;? </p> <p>銆銆#MIN HOUR DAY MONTH DAYOFWEEK COMMAND </p> <p>銆銆#姣?#28598;?#37827;?#28051;?鐐?0鍒?</p> <p>銆銆10 6 * * * date </p> <p>銆銆#姣?#28051;釜灏忔椂 </p> <p>銆銆0 */2 * * * date (solaris 5.8浼?#28052;庝笉鏀?#37816;?#23005;?#32457;?#37712;欐硶) </p> <p>銆銆#鏅?#28051;?1鐐瑰埌鏃?#28051;?鐐?#28052;?#38338;?#23011;?#28051;釜灏忔椂锛?#37827;?#28051;?鐐?</p> <p>銆銆0 23-7/2锛? * * * date </p> <p>銆銆#姣忎釜鏈?#37928;?鍙峰拰姣忎釜绀?#37815;?#37928;勭鎷?#28051;?#22476;绀?#37815;?#28051;?#37928;勬棭涓?1鐐?</p> <p>銆銆0 11 4 * mon-wed date </p> <p>銆銆#1鏈?#28000;?#37827;?#37827;?#28051;?鐐?</p> <p>銆銆0 4 1 jan * date </p> <p>銆銆琛?#37711;?#38171;氬湪浣?#37922;crontab鐨勬椂鍊?#38171;?#29781;佺壒鍒?#23049;剰鐨?#37828;?#26473;?#29723;岃剼鏈?#28051;兘澶?#29825;?#38338;埌鐨?#37916;?#28583;?#37721;?#38322;?#37724;屽?#25779;墠娴?#29831;?#37916;?#28583;?#28051;?#37928;?#37916;?#28583;?#37721;?#38322;?#37832;?#36423;?#28051;?#22183;锛?#28051;?#37340;姣旇緝淇?#38340;?#37928;勫?#27693;硶鏄湪杩?#29723;?#37928;勮剼鏈?#32459;?#25652;?#28051;?#38007;?#29723;?#29825;?#32515;?#37916;?#28583;?#37721;?#38322;?export) </p> <p>銆銆(1)?#21403;寤?#28051;?#37340;鏂?#28000;禼rond.txt濡?#28051;?#38171;?姣?#28598;?#37827;?#28051;?鐐?6鍒?#38322;?#37826;?#37722;姩 </p> <p>銆銆36 5 * * * reboot </p> <p>銆銆(2)涓?#28028;犲埌/opt?#27952;褰?</p> <p>銆銆(3)杩?#29723;?#37723;戒护 </p> <p>銆銆crontab /opt/crond.txt </p> <p>銆銆crontab -l </p> <p>銆銆璁?#38320;嶇疆鏂?#28000;?#37922;熸晥锛?#28641;?#37835;?#29825;?#38320;嶇疆鏂?#28000;?#37922;熸晥锛?#26473;?#23536;?#38322;?#37826;?#37722;姩cron锛?#37714;?#29825;?#38171;?#37827;劧姣忎釜鐢?#37812;蜂笅鐨刢ron閰嶇疆鏂?#28000;?#28103;敼鍚?#37510;備篃瑕?#38322;?#37826;?#37722;姩cron鏈?#37716;?#37731;?#37510;?</p> <p>銆銆?#28266;Fedora ?#25328;Redhat涓?#38171;?#37812;戜滑搴旇鐢?#38171;?</p> <p>銆銆[root@localhost ~]# /etc/init.d/crond restart </p> <p>銆銆濡?#37835;?#29825;crond ?#28266;寮鏈烘椂杩?#29723;?#38171;屽?#26055;?#25980;鍙?#37711;?#26473;?#29723;岀骇鍒?#38171;?</p> <p>銆銆[root@localhost ~]# chkconfig --levels 35 crond on </p> <p>銆銆service crond status ?#29025;?#28229; cron鏈?#37716;?#37912;?#37804;?#38171;?#28641;?#37835;滄病鏈?#37722;姩鍒?service crond start鍚姩瀹?#38171;?cron鏈?#37716;?#37828;?#28051;?#37340;?#30078;?#26882;鎵?#29723;?#37928;勬湇鍔?#38171;?#37721;?#28000;?#38315;?#26473;crontab 鍛戒护娣诲姞鎴?#38000;呯紪杈戦渶瑕佸畾?#26882;鎵?#29723;?#37928;?#28000;诲姟 <br /> <br /> </p> <span id="zoom" class="a14c"> <p style="text-indent: 2em"> <p style="text-indent: 2em"> <p style="text-indent: 2em">Crontab鏂?#28000;?#37928;勬瘡涓琛?#37922;?#37711;釜鍩?minutes銆乭ours銆乨ay of month銆乵onth銆乨ay of week銆?command)缁?鎴?#38171;屽煙涔?#38338;?#37922;?#32460;?#37837;?#37812;朤ab鍒?#23534;锛?#37711;?#28051;?#38171;? <p style="text-indent: 2em">minutes锛?鍒嗛挓鍩?#38171;?#37706;?#37928;勮?#20904;洿鏄??#22476;59 <p style="text-indent: 2em">hours锛?灏忔椂鍩?#38171;?#37706;?#37928;勮?#20904;洿鏄??#22476;23 <p style="text-indent: 2em">day of month锛?鏃?#37832;?#38171;?#37706;?#37928;勮?#20904;洿鏄??#22476;31 <p style="text-indent: 2em">month锛?鏈?#28000;?#38171;?#37706;?#37928;勮?#20904;洿鏄??#22476;12 <p style="text-indent: 2em">day of week锛?鏄?#37832;?#38171;?#37706;?#37928;勮?#20904;洿鏄??#22476;6锛?#37828;?#37832;?#37827;?#37706;?#28051;? <p style="text-indent: 2em">command锛??#22669;瑕?#26473;?#29723;?#37928;?#37723;戒护 <p style="text-indent: 2em">濡?#37835;?#28051;?#37340;鍩?#37828;?锛?#29723;?#37828;?#37723;戒护鍙?#28000;湪璇?#37737;熸墍鏈?#37721;兘鐨?#37721;?#37706;艰?#20904;洿鍐?#37813;?#29723;?#37510;? <p style="text-indent: 2em">濡?#37835;?#28051;?#37340;鍩?#37828;?#37922;?#26473;?#28699;?#32471;殧寮鐨?#28051;釜?#26271;瀛?#38171;?#29723;?#37828;?#37723;戒护鍙?#28000;湪涓釜?#26271;瀛?#28052;?#38338;?#37928;勮?#20904;洿鍐?#37813;?#29723;?#38171;?#37718;呮嫭涓釜?#26271;瀛?鏈?#38892;?#38171;?#37510;? <p style="text-indent: 2em">濡?#37835;?#28051;?#37340;鍩?#37828;?#37922;?#38315;楀彿?#27559;寮鐨?#28051;绯?#37714;楀?#32513;勬垚鐨?#38171;?#29723;?#37828;?#37723;戒护鍙?#28000;湪杩欎簺鍊?#32513;勬垚鐨勮?#20904;洿鍐?#37813;?#29723;?#37510;? <p style="text-indent: 2em">濡?#37835;?#37827;?#37832;?#37737;熷拰鏄?#37832;?#37737;?#38318;?#37832;?#37706;?#38171;?#37714;?#26473;欎袱?#37340;鍩?#38318;?#37832;?#37825;?#37510;? <p style="text-indent: 2em">缂?#37712;欎竴?#37340;鏂?#28000;?#38171;?#37922;?#28000;?#37722;姩鑷姩澶?#28000;?#26473;涚銆? <p style="text-indent: 2em"> <p style="text-indent: 2em">cd /opt <p style="text-indent: 2em">touch reboot.txt <p style="text-indent: 2em">?#28266;reboot.txt涓?#23075;诲姞涓涓?#37712;呭: <p style="text-indent: 2em">0 4 * * * reboot <p style="text-indent: 2em"> <p style="text-indent: 2em">crontab /opt/reboot.txt <p style="text-indent: 2em">鐢crontab -e缂?#26440;戝畾?#26882;鎿?#28003;?#38171;?#28186;?#28641;?#37716;犲叆涓嬭鍛戒护锛? <p style="text-indent: 2em">鐢crontab 锛峫鍛戒护鏉煡?#28229; <p style="text-indent: 2em"> <p style="text-indent: 2em">娉剰:闇瑕?#37722;姩鏈?#37716;?娣诲?#29362;湪rc.local涓? <p style="text-indent: 2em"> <p style="text-indent: 2em">閲?#37722;痗rond浠诲姟 <p style="text-indent: 2em"> <p style="text-indent: 2em">/etc/init.d/cron restart (ubuntu涓? <p style="text-indent: 2em"> <p style="text-indent: 2em">绗?#28051;绉??#28266;Fedora鎴朢edhat 绛?#28000;RPM鍖呯鐞?#37928;勭?#33636;粺涓?#38171;? <p style="text-indent: 2em"> <p style="text-indent: 2em">[root@localhost ~]# /etc/init.d/crond start <p style="text-indent: 2em">[root@localhost ~]# /etc/init.d/crond stop <p style="text-indent: 2em">[root@localhost ~]# /etc/init.d/crond restart <p style="text-indent: 2em"> <p style="text-indent: 2em">/etc/rc.d/init.d/crond restart <p style="text-indent: 2em"> <p style="text-indent: 2em">鍛戒护绠浠? <p style="text-indent: 2em"> <p style="text-indent: 2em">crontab-鎿?#28003;?#23011;忎釜鐢?#37812;?#37928;?#28729;堟姢绋?#25652;忓拰璇?#37813;?#29723;?#37928;勬椂闂?#29723;?#37510;? <p style="text-indent: 2em"> <p style="text-indent: 2em">閮?#37714;?#37721;傛暟璇?#37828;? <p style="text-indent: 2em">crontab file [-u user]-鐢?#37816;囧畾鐨勬枃浠?#37831;?#28000;洰鍓?#37928;刢rontab銆? <p style="text-indent: 2em">crontab-[-u user]-鐢?#37837;囧噯杈撳叆鏇?#28000;洰鍓?#37928;刢rontab. <p style="text-indent: 2em">crontab-1[user]-鍒楀嚭鐢?#37812;风洰鍓?#37928;刢rontab. <p style="text-indent: 2em">crontab-e[user]-缂?#26440;?#37922;?#37812;风洰鍓?#37928;刢rontab. <p style="text-indent: 2em">crontab-d[user]-鍒犻櫎鐢?#37812;风洰鍓?#37928;刢rontab. <p style="text-indent: 2em">crontab-c dir- 鎸囧畾crontab鐨勭洰褰?#37510;? <p style="text-indent: 2em">crontab鏂?#28000;?#37928;勬牸寮?#38171;M H D m d cmd. <p style="text-indent: 2em">M: 鍒嗛挓锛?-59锛?#37510;? <p style="text-indent: 2em">H锛氬?#24532;椂锛?-23锛?#37510;? <p style="text-indent: 2em">D锛?#28598;?#38171;?-31锛?#37510;? <p style="text-indent: 2em">m: 鏈?#38171;?-12锛?#37510;? <p style="text-indent: 2em">d: 涓鏄?#37832;?#37712;?#37928;?#28598;?#38171;?~6锛?涓?#37828;?#37832;?#28598;?#38171;?#37510;? <p style="text-indent: 2em">cmd瑕?#26473;?#29723;?#37928;勭搴?#38171;?#32459;?#25652;?#29722;?#38315;佸叆sh鎵?#29723;?#38171;?#26473;欎釜shell鍙?#37832;USER,HOME,SHELL杩欎?#22793;釜鐜?#28583;?#37721;?#38322;?#37510;? <p style="text-indent: 2em">涓嬮潰鏄?#28051;?#37340;渚?#28699;?#37826;?#28000;?#38171;? <p style="text-indent: 2em"> <p style="text-indent: 2em"> <center><ccid_nobr> <table border="1" cellspacing="0" bordercolorlight="black" bordercolordark="#ffffff" cellpadding="2" width="400" align="center"> <tbody> <tr> <td style="font-size: 9pt" class="code" bgcolor="#e6e6e6"> <pre><ccid_code>#MIN HOUR DAY MONTH DAYOFWEEK COMMAND #姣?#28598;?#37827;?#28051;?鐐? 106* * * date #姣?#28051;釜灏忔椂 0*/2* * * date #鏅?#28051;?1鐐瑰埌鏃?#28051;?鐐?#28052;?#38338;?#23011;?#28051;釜灏忔椂锛?#37827;?#28051;?#38318;?#37904;? 0 23-7/2锛?* * * date #姣忎釜鏈?#37928;?鍙峰拰姣忎釜绀?#37815;?#37928;勭鎷?#28051;?#22476;绀?#37815;?#28051;?#37928;勬棭涓?1鐐? 0 11 4* mon-wed date #1鏈?#28000;?#37827;?#37827;?#28051;?鐐? 0 4 1 jan* date ?#23510;渚? lark:~>crontab-1 鍒楀嚭鐢?#37812;风洰鍓?#37928;刢rontab. #MIN HOUR DAY MONTH DAYOFWEEK COMMAND 10 6* * * date 0*/2* * * date 0 23-7/2,8 * * * date lark:~></ccid_code></pre> </td> </tr> </tbody> </table> </ccid_nobr></center> <p style="text-indent: 2em"> <p style="text-indent: 2em">锛?#29840;?#28000;荤紪杈?#38171;?#27996;?#28699;?#38171;?</p> </span> <img src ="http://www.67529968.com/lingy/aggbug/286193.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2009-07-10 11:01 <a href="http://www.67529968.com/lingy/archive/2009/07/10/286193.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>Linux?#30078;?#26882;浠诲姟绯荤粺Cron?#21446;闂?/title><link>http://www.67529968.com/lingy/archive/2009/07/09/286135.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Thu, 09 Jul 2009 10:38:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2009/07/09/286135.html</guid><description><![CDATA[<p>cron鏄?#28051;?#37340;linux涓?#37928;勫畾?#26882;鎵?#29723;屽伐鍏?#38171;?#37721;?#28000;湪鏃?#38343;浜哄伐骞?#26864;?#37928;勬?#21613;喌涓嬭繍琛?#28003;?#28051;?#37510;?#37922;?#27996;嶤ron 鏄疞inux鐨?#37712;呯疆鏈?#37716;?#38171;?#28003;嗗?#20903;笉鑷姩璧?#37833;?#38171;?#37721;?#28000;?#37922;?#28000;?#28051;?#37928;勬?#35268;硶鍚姩銆?#37711;?#38338;?#26473;欎釜鏈?#37716;?#38171;?/p> <p> </p> <p>/sbin/service crond start //鍚姩鏈?#37716;?/p> <p>/sbin/service crond stop //鍏?#38338;?#37832;?#37716;?/p> <p>/sbin/service crond restart //閲?#37722;?#37832;?#37716;?/p> <p>/sbin/service crond reload //閲?#37826;拌?#34249;叆閰嶇疆</p> <p> </p> <p> </p> <p>浣?#28052;?#37721;?#28000;?#28751;?#26473;欎釜鏈?#37716;湪绯荤粺鍚姩鐨勬椂鍊欒嚜?#23017;鍚姩锛?/p> <p> </p> <p>?#28266;/etc/rc.d/rc.local杩欎釜鑴?#37832;?#37928;勬湯灏?#37716;?#28051;?#38171;?/p> <p>/sbin/service crond start</p> <p> </p> <p>鐜板湪Cron杩欎釜鏈?#37716;?#23480;?#32513;忓湪杩涚?#23342;?#23684;潰浜?#38171;?#37812;戜滑灏?#37721;?#28000;?#37922;?#26473;欎釜鏈?#37716;?#27996;?#38171;孋ron鏈?#37716;?#37819;愪緵浠?#28051;?#37713;犵鎺?#37721;?#28186;?#28598;?#28729;?#28003;?#37922;?#38171;?/p> <p> </p> <p><strong>1.鐩?#37818;?#37922;crontab鍛戒护缂?#26440;?/strong></p> <p> </p> <p>cron鏈?#37716;?#37819;愪緵crontab鍛戒护鏉?#29825;惧畾cron鏈?#37716;?#37928;?#38171;?#28000;?#28051;?#37828;?#26473;欎釜鍛戒护鐨?#28051;浜?#37721;傛暟涓?#29831;?#37828;?#38171;?/p> <p> </p> <p>crontab -u //璁惧畾鏌愪釜鐢?#37812;?#37928;刢ron鏈?#37716;?#38171;?#28051;鑸瑀oot鐢?#37812;峰湪鎵?#29723;?#26473;欎釜鍛戒护鐨勬椂鍊?#38343;瑕?#23005;?#37721;傛暟</p> <p> </p> <p>crontab -l //鍒楀嚭鏌愪釜鐢?#37812;cron鏈?#37716;?#37928;?#29831;?#32513;?#37712;呭</p> <p> </p> <p>crontab -r //鍒犻櫎?#30149;?#37340;鐢?#37812;?#37928;刢ron鏈?#37716;?/p> <p> </p> <p>crontab -e //缂?#26440;戞?#24874;釜鐢?#37812;?#37928;刢ron鏈?#37716;?/p> <p> </p> <p>姣?#28641;?#29831;磖oot?#29025;鐪嬭嚜?#32321;鐨刢ron璁?#32515;?#38171;歝rontab -u root -l</p> <p> </p> <p>鍐?#28186;?#28641;?#38171;宺oot鎯冲?#29371;櫎fred鐨刢ron璁?#32515;?#38171;歝rontab -u fred -r</p> <p> </p> <p>?#28266;缂?#26440;慶ron鏈?#37716;椂锛岀紪杈?#37928;?#37712;呭?#35268;湁涓浜?#37837;?#23534;?#37724;岀害?#30078;锛?#26440;撳叆锛歝rontab -u root -e</p> <p> </p> <p>杩涘叆vi缂?#26440;戞寮?#38171;岀紪杈?#37928;?#37712;呭涓?#30078;瑕?#32471;?#37722;?#28051;嬮潰鐨勬牸寮?#38171;?/1 * * * * ls >> /tmp/ls.txt</p> <p> </p> <p>杩欎釜鏍?#23534;?#37928;勫墠涓閮?#37714;?#37828;?#28725;规椂闂?#37928;勮?#24807;畾锛?#37722;庨潰涓閮?#37714;?#37828;?#29781;?#37813;?#29723;?#37928;?#37723;戒护锛?#28641;?#37835;?#29781;?#37813;?#29723;?#37928;?#37723;戒护澶?#28598;?#38171;?#37721;?#28000;妸杩欎簺鍛戒护鍐欏埌涓?#37340;鑴?#37832;?#38322;岄潰锛岀劧鍚庡湪杩?#38322;?#37929;?#37818;皟鐢?#26473;欎釜鑴?#37832;?#28751;?#37721;?#28000;?#27996;?#38171;岃皟鐢?#37928;勬椂鍊?#29825;?#23536;楀啓鍑?#37723;戒护鐨?#28729;屾暣?#30718;寰?#37510;傛椂闂?#37928;勮?#24807;畾鎴戜滑鏈?#28051;?#30078;鐨勭害?#30078;锛屽墠?#28528;?#31794;?#37340;*鍙蜂唬琛簲?#37340;?#26271;瀛?#38171;屾暟瀛?#37928;?#37721;?#37706;艰?#20904;洿?#25328;鍚?#28052;夊涓?#38171;?/p> <p> </p> <p>鍒嗛挓銆锛?-59锛?/p> <p> </p> <p>灏忔檪銆锛?-23锛?/p> <p> </p> <p>鏃?#37832;?#37510;锛?-31锛?/p> <p> </p> <p>鏈?#28000;?#37510;锛?-12锛?/p> <p> </p> <p>鏄?#37832;?#37510;锛?-6锛?/0浠?#29723;?#37828;?#37832;?#28598;?/p> <p> </p> <p>?#27342;浜嗘暟瀛?#26473;?#37832;?#37713;犱釜?#37340;鐗规畩鐨?#32471;?#37721;峰氨鏄?*"銆?/"?#25328;"-"銆?,"锛?浠?#29723;墍鏈?#37928;?#37721;?#37706;艰?#20904;洿鍐?#37928;勬暟瀛?#38171;?/"浠?#29723;?#23011;?#37928;勬剰鎬?"*/5"琛?#32448;?#23011;??#37340;鍗?#28003;?#38171;?-"浠?#29723;?#28000;庢?#24874;釜?#26271;瀛楀埌鏌愪釜?#26271;瀛?","鍒?#23534;鍑犱釜绂?#37825;?#37928;勬暟瀛?#37510;備互涓?#28051;?#37713;犱釜渚?#28699;?#29831;?#37828;?#38338;?#26864;?#38171;?/p> <p> </p> <p>姣?#28598;?#37827;?#28051;?鐐?/p> <p> </p> <p>0 6 * * * echo "Good morning." >> /tmp/test.txt //娉剰鍗曠函echo锛?#28000;庡睆骞?#28051;婄湅?#31497;?#22476;浠?#28003;曡緭鍑?#38171;屽洜涓篶ron?#22968;浠?#28003;曡緭鍑?#38318;email?#22476;root鐨?#28103;?#32480;?#27996;?#37510;?/p> <p> </p> <p>姣?#28051;釜灏忔椂</p> <p> </p> <p>0 */2 * * * echo "Have a break now." >> /tmp/test.txt</p> <p> </p> <p>鏅?#28051;?1鐐瑰埌鏃?#28051;?鐐?#28052;?#38338;?#23011;?#28051;釜灏忔椂锛?#37827;?#28051;?#37711;?#37904;?/p> <p> </p> <p>0 23-7/2锛? * * * echo "Have a good dream锛?#38171;? >> /tmp/test.txt</p> <p> </p> <p>姣忎釜鏈?#37928;?鍙峰拰姣忎釜绀?#37815;?#37928;勭鎷?#28051;?#22476;绀?#37815;?#28051;?#37928;勬棭涓?1鐐?/p> <p> </p> <p>0 11 4 * 1-3 command line</p> <p> </p> <p>1鏈?鏃?#37827;?#28051;?鐐?/p> <p> </p> <p>0 4 1 1 * command line</p> <p> </p> <p>姣?#23046;?#32514;?#26440;?#28729;?#37836;愪釜鐢?#37812;?#37928;刢ron璁?#32515;?#37722;?#38171;宑ron鑷姩?#28266;/var/spool/cron涓?#37922;?#37812;?#28051;?#37340;涓庢鐢?#37812;?#37722;?#37722;?#37928;勬枃浠?#38171;屾鐢?#37812;?#37928;刢ron淇?#37805;?#38318;?#29825;?#35120;曞湪杩欎釜鏂?#28000;?#28051;?#38171;?#26473;欎釜鏂?#28000;?#37828;笉鍙?#28000;?#37929;?#37818;?#32514;?#26440;?#37928;?#38171;?#37721;?#37721;?#28000;?#37922;crontab -e 鏉?#32514;?#26440;?#37510;俢ron鍚姩鍚庢瘡杩?#28051;浠介挓璇?#28051;娆?#26473;欎釜鏂?#28000;?#38171;屾?#29025;鏄惁瑕?#37813;?#29723;岄?#23684;潰鐨?#37723;戒护銆?#37733;?#23005;?#23005;?#37826;?#28000;?#28103;敼鍚庝笉闇瑕?#38322;?#37826;?#37722;姩cron鏈?#37716;?#37510;?/p> <p> </p> <p><strong>2.缂?#26440;?etc/crontab 鏂?#28000;堕?#23943;疆cron</strong></p> <p> </p> <p>cron鏈?#37716;?#23011;?#37714;嗛?#29110;笉浠?#29781;?#29831;?#28051;娆?var/spool/cron鍐?#37928;勬墍鏈?#37826;?#28000;?#38171;?#26473;?#38343;瑕?#29831;?#28051;娆?etc/crontab,鍥?#23005;?#37812;戜滑閰嶇疆杩欎釜鏂?#28000;朵篃?#20824;杩?#37922;?cron鏈?#37716;?#37707;?#28051;浜?#27996;?#37807;?#37510;?#37922;crontab閰嶇疆鏄?#38333;?#28725;规?#24874;釜鐢?#37812;?#37928;?#38171;岃岀紪杈?etc/crontab鏄?#38333;?#28725;?#32495;荤粺鐨?#28000;诲姟銆傛鏂?#28000;?#37928;勬枃浠?#37837;?#23534;?#37828;?#38171;?/p> <p> </p> <p>SHELL=/bin/bash</p> <p>PATH=/sbin:/bin:/usr/sbin:/usr/bin</p> <p>MAILTO=root //濡?#37835;?#37713;?#37916;伴敊璇?#38171;?#37812;?#38000;?#37832;夋暟鎹?#26440;?#37713;?#38171;屾暟鎹?#28003;?#28051;洪偖浠?#37721;?#32513;?#26473;欎釜甯?#37721;?/p> <p>HOME=/ //浣?#37922;?#38000;?#26473;?#29723;?#37928;勮矾寰?杩?#38322;?#37828;?#37837;圭洰褰?/p> <p># run-parts</p> <p>01 * * * * root run-parts /etc/cron.hourly //姣?#28751;忔椂鎵?#29723;?etc/cron.hourly鍐?#37928;勮剼鏈?/p> <p>02 4 * * * root run-parts /etc/cron.daily //姣?#28598;?#37813;?#29723;?etc/cron.daily鍐?#37928;勮剼鏈?/p> <p>22 4 * * 0 root run-parts /etc/cron.weekly //姣?#37828;?#37832;?#37813;?#29723;?etc/cron.weekly鍐?#37928;勮剼鏈?/p> <p>42 4 1 * * root run-parts /etc/cron.monthly //姣?#37832;堝幓鎵?#29723;?etc/cron.monthly鍐?#37928;勮剼鏈?/p> <p> </p> <p>澶?#28729;?#23049;剰"run-parts"杩欎釜鍙傛暟浜?#38171;?#28641;?#37835;?#37720;?#37818;?#26473;欎釜鍙傛暟鐨?#29831;?#38171;?#37722;庨潰灏?#37721;?#28000;?#37712;?#29781;?#26473;?#29723;?#37928;勬?#24874;釜鑴?#37832;?#37722;?#38171;岃屼笉鏄?#37826;?#28000;?#28598;?#37722;?#27996;?/p> <img src ="http://www.67529968.com/lingy/aggbug/286135.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2009-07-09 18:38 <a href="http://www.67529968.com/lingy/archive/2009/07/09/286135.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>over partition by涓巊roup by 鐨勫尯鍒?/title><link>http://www.67529968.com/lingy/archive/2009/06/29/284658.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Mon, 29 Jun 2009 11:04:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2009/06/29/284658.html</guid><description><![CDATA[<div id="message10586007" class="t_msgfont">鍚?#28003;?#28610;?#38171;?br /> over partition by 涓?group by 閮?#37828;?#28051;?#32513;?#29825;?#32491;?#37713;芥暟鐢?#38171;?#26473;欎袱?#37340;鏈?#28000;涔?#37718;?#37714;?#37723;紵<br /> ?#27952;鍓?#37812;?#37721;煡閬?#28051;?#37340;杩?#37837;?#37928;勫尯鍒?#38171;?br /> 姣?#28641;?#37832;?#28051;寮?#29723;saraly:CREATE TABLE SALARY AS SELECT 'A' NAME,10 DEPT,1000 SALARY FROM DUAL UNION ALL SELECT 'B',10,2000 FROM DUAL UNION ALL SELECT 'C' ,20,1500 FROM DUAL UNION ALL SELECT 'D',20,3000 FROM DUAL UNION ALL<br /> SELECT 'E',10,1000 FROM DUAL;<br /> NAME DEPT SALARY<br /> A         10     1000<br /> B         10     2000<br /> C         20     1500<br /> D         20     3000<br /> E         10     1000   <br /> 鐢over partition by 鎴?#28751;?#37721;?#28000;煡璇埌姣?#28003;?#37723;樺伐鏈?#37833;?#37928;?#37711;蜂綋淇?#37805;?#37724;屽?#20905;墍?#28266;閮?#38338;?#37928;勬诲伐璧?#38171;?br /> select name,dept,salary,sum(salary) over (partition by dept) total_salary from salary;  <br /> name       dept         salary      tatal_salary<br /> A        10        1000        4000<br /> B        10        2000        4000<br /> E        10        1000        4000<br /> C        20        1500        4500<br /> D        20        3000        4500<br /> <br /> 鐢goup by 灏辨病鍔炴硶鍋氬埌杩?#37904;?#38171;?#37721;兘?#29025;璇埌姣忎釜閮?#38338;?#37928;勬诲伐璧?#38171;?br /> select dept,sum(salary) total_salary from salary group by dept<br /> dept        total_salary<br /> 10        4000<br /> 20        4500<br /> 鍙?#28598;over partion by 杩?#37721;?#28000;?#37707;氬埌?#29025;璇?#23011;?#28003;?#37723;樺伐?#23856;閮?#38338;?#37804;诲伐璧?#37928;?#37927;?#37714;?#23011;?#38171;?br /> select name,dept,salary,salary*100/sum(salary) over (partition by dept) percent from salary;<br /> <br /> name       dept         salary     percent<br /> A        10        1000        25<br /> B        10        2000        50<br /> E        10        1000        25<br /> C        20        1500        33.3333333333333<br /> D        20        3000        66.6666666666667<br /> 鐢group by 涔熸病鍔炴硶鍋氬埌杩欎釜.?#31497;?#29025;閬?#37812;?#37928;勭悊瑙?#23005;笉姝?#32429;?#38171;?#29831;?#37722;?#28003;?#37832;?#37721;?#37816;?#37904;?#38171;岀壒鍒?#37828;痮ver partition by 涓巊roup by 鐨?#37831;?#28598;?#37718;?#37714;?#29831;?#37722;?#28003;?#28051;璧?#37714;嗕韩锛岃阿璋?#38171;?br /> <br /> 20        4500<br /> <br /> </div> <img src ="http://www.67529968.com/lingy/aggbug/284658.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2009-06-29 19:04 <a href="http://www.67529968.com/lingy/archive/2009/06/29/284658.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>Oracle涓?#37928;NULL锛?#37711;?#38171;?/title><link>http://www.67529968.com/lingy/archive/2009/06/29/284559.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Mon, 29 Jun 2009 02:59:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2009/06/29/284559.html</guid><description><![CDATA[<p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;?>鏈杩戝湪璁哄潧涓?#32513;?#29999;哥湅?#22476;锛屽緢澶?#27996;?#37819;?#37713;哄拰<span lang="EN-US">NULL鏈夊叧鐨?#38338;?#26864;?#37510;侼ULL鍏?#28729;?#37828;暟鎹?#25652;?#28051;?#37911;规湁鐨勭?#35826;瀷锛孫racle涓?#23536;?#28598;?#28729;?#37828;?#37713;?#37916;?#37928;勯敊璇?#38318;?#37828;拰NULL鏈夊叧鐨?#37510;?/span></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;?>鎵撶?#26947;畝鍗?#37928;勬荤粨涓涓?span lang="EN-US">NULL鐨勭浉鍏崇煡璇?#37510;?/span></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;?>杩欎竴?#30226;鎻?#26473;?#28051;涓嬪湪<span lang="EN-US">SQL?#25328;PLSQL涓?#28051;浜?#28598;勭悊NULL鐨?#28051;浜?#38338;?#26864;?#37510;?/span></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;? lang="EN-US">Oracle涓?#37928;NULL锛?#28051;锛?#38171;?a href="http://yangtingkun.itpub.net/post/468/244434">http://yangtingkun.itpub.net/post/468/244434</a></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;? lang="EN-US">Oracle涓?#37928;NULL锛?#27996;?#38171;?#38171;?a href="http://yangtingkun.itpub.net/post/468/245107">http://yangtingkun.itpub.net/post/468/245107</a></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;? lang="EN-US">Oracle涓?#37928;NULL锛?#28051;?#38171;?#38171;?a href="http://yangtingkun.itpub.net/post/468/245259">http://yangtingkun.itpub.net/post/468/245259</a></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;? lang="EN-US">Oracle涓?#37928;NULL锛堝洓锛?#38171;?a href="http://yangtingkun.itpub.net/post/468/245697">http://yangtingkun.itpub.net/post/468/245697</a></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;? lang="EN-US">Oracle涓?#37928;NULL锛堜簲锛?#38171;?a href="http://yangtingkun.itpub.net/post/468/247492">http://yangtingkun.itpub.net/post/468/247492</a></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;? lang="EN-US">Oracle涓?#37928;NULL锛?#37711;?#38171;?#38171;?a href="http://yangtingkun.itpub.net/post/468/251496">http://yangtingkun.itpub.net/post/468/251496</a></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;? lang="EN-US">Oracle涓?#37928;NULL锛?#28051;?#38171;?#38171;?a href="http://yangtingkun.itpub.net/post/468/258467">http://yangtingkun.itpub.net/post/468/258467</a></span></p> <p style="text-indent: 21pt"></p> <br /> <span style="display: none">8\![ Q!x;]$Yf0</span> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;? lang="EN-US">NULL鐨勬渶澶?#37928;勭壒鐐瑰氨鏄?#28051;釜NULL鏄笉?#27977;绛?#37928;?#37510;?#28641;?#37835;?#37922;?#32475;?#37721;?#37833;?#37714;?#37826;?#28051;釜NULL鏄惁?#27977;绛夊?#26944;埌鐨勭粨鏋?#28051;?#30078;鏄疦ULL銆備?#24225;敮涓?#23475;鏉?#37928;勭壒鐐?#28052;?#37721;?#28000;湅?#22476;锛屽浜庡缓绔?#27996;嗗敮涓?#23475;鏉?#37928;?#37714;?#38171;孫racle鍏?#29825;?#37819;掑叆澶氫釜NULL鍊?#38171;?#26473;欐椂鍥?#28051;Oracle?#31497;璁?#28051;?#26473;欎簺NULL鏄浉绛?#37928;?#37510;?/span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>SQL> CREATE TABLE T (ID NUMBER, CONSTRAINT UN_T UNIQUE(ID));</font></span></p> <p><span style="font-size: 10.5pt"><font face="瀹?#28003;?>琛?#23480;?#37714;涘缓銆?/font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>SQL> INSERT INTO T VALUES (1);</font></span></p> <p><span style="font-size: 10.5pt"><font face="瀹?#28003;?>宸?#37714;涘缓<span lang="EN-US"> 1 琛?#37510;?/span></font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>SQL> INSERT INTO T VALUES (1);<br /> <span style="display: none">| Pw6I)A#P,x_0</span>INSERT INTO T VALUES (1)<br /> <span style="display: none">+h:w|3~ N0</span>*<br /> <span style="display: none">LCB-P#b{$C0</span>ERROR 浣?#27996;?#32471;?1 琛?<br /> <span style="display: none">f9i vJ Y%T0</span>ORA-00001: 杩?#37721;嶅敮涓?#23475;鏉?#37833;?#28000;?(YANGTK.UN_T)</font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><br /> <span style="display: none">&rSq _0P7QvYN0</span><font face="瀹?#28003;?>SQL> INSERT INTO T VALUES (NULL);</font></span></p> <p><span style="font-size: 10.5pt"><font face="瀹?#28003;?>宸?#37714;涘缓<span lang="EN-US"> 1 琛?#37510;?/span></font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>SQL> INSERT INTO T VALUES (NULL);</font></span></p> <p><span style="font-size: 10.5pt"><font face="瀹?#28003;?>宸?#37714;涘缓<span lang="EN-US"> 1 琛?#37510;?/span></font></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;?>浣?#37828;?#37832;?#37928;勬椂鍊?#38171;?span lang="EN-US">Oracle?#32048;璁?#28051;篘ULL鏄浉鍚?#37928;?#38171;?#23011;?#28641;傚湪GROUP BY?#25328;DISTINCT鎿?#28003;?#28051;?#37510;?#26473;欎釜?#26882;鍊?#38171;孫racle?#32048;璁?#28051;烘墍鏈?#37928;NULL閮?#37828;?#28051;绫?#37928;?#37510;?/span></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;?>杩?#37832;?#28051;绉?#37807;呭喌锛屽氨鏄湪<span lang="EN-US">DECODE鍑芥暟涓?#37510;?#28641;?#37835;?#29723;?#26440;?#23534;?#28051;篋ECODE(COL, NULL, 0, 1)锛岄偅涔?#28641;?#37835;淐OL鐨?#37706;?#28051;篘ULL锛孫racle?#32048;璁?#28051;?#26473;欑鎯呭喌涓?#32471;?#27996;屼釜鍙傛暟鐨NULL鍊肩浉鍖归厤锛屼細杩?#37733;?銆備笉杩?#26473;?#38322;?#37721;?#37828;?#32513;欎?#28888;劅瑙塏ULL鍊?#37828;浉绛?#37928;?#38171;孫racle?#28266;瀹?#37916;癉ECODE鍑芥暟鐨勬椂鍊?#38171;?#28000;嶇劧鏄?#38315;?#26473;IS NULL鐨勬柟寮?#26473;?#29723;?#37928;?#37714;?#37826;?#37510;?/span></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;?>瀵?#27996;?#28598;?#28598;氭暟鐨?#29999;?#37922;?#37713;芥暟鏉?#29831;?#38171;?#28641;?#37835;?#26440;撳叆涓?span lang="EN-US">NULL锛?#37714;?#26440;?#37713;?#28052;?#37828;疦ULL銆侼VL銆丯VL2銆丏ECODE?#25328;||鎿?#28003;?#37828;釜渚?#28598;?#37510;備粬?#28369;?#28266;杈撳叆鍙傛暟涓篘ULL鐨勬椂鍊?#38171;岀粨鏋?#37721;?#38003;戒笉鏄疦ULL銆備笉杩囧?#25492;粨鍏跺師鍥?#37828;?#37733;?#28051;?#38171;?#26473;欎簺鍑芥暟閮?#37832;?#28598;氫釜鍙傛暟锛屽綋澶氫釜鍙傛暟?#31497;鍏?#28051;篘ULL?#26882;锛岀粨鏋?#37721;?#38003;戒笉鏄疦ULL锛?#28641;?#37835;?#26440;撳叆鍙傛暟鍧?#28051;篘ULL锛岄偅涔?#23536;楀埌鐨勮緭鍑虹粨鏋?#28052;?#37828;疦ULL銆?/span></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;? lang="EN-US">NULL杩?#37832;?#28051;?#37340;鐗?#37904;?#38171;屽氨鏄?#28051;鑸仛?#27878;鍑芥暟?#31497;?#32048;澶勭悊NULL鍊?#37510;備笉绠?#37828;MAX銆丮IN銆丄VG杩?#37828;疭UM锛?#26473;欎簺?#20187;?#27878;鍑芥暟閮戒笉?#32048;澶勭悊NULL銆?#23049;剰杩?#38322;?#29831;?#37928;勪笉?#32048;澶勭悊NULL锛?#37828;?#37816;囪仛?#27878;鍑芥暟?#32048;鐩?#37818;?#36423;界暐NULL鍊?#29825;?#35120;?#37928;?#28699;樺湪銆傞櫎闈?#37828;仛?#27878;鍑芥暟澶勭悊鐨?#37714;?#28051;?#37718;呭惈鐨?#37711;?#38318;?#29825;?#35120;?#38318;?#37828;疦ULL锛?#26473;欑鎯呭喌涓?#38171;?#28051;婇潰杩欎簺?#20187;?#27878;鍑芥暟?#32048;杩?#37733;NULL鍊?#37510;?/span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>SQL> DELETE T WHERE ID = 1;</font></span></p> <p><span style="font-size: 10.5pt"><font face="瀹?#28003;?>宸?#37714;犻櫎<span lang="EN-US"> 1 琛?#37510;?/span></font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>SQL> SELECT NVL(TO_CHAR(ID), 'NULL') FROM T;</font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>NVL(TO_CHAR(ID),'NULL')<span style="display: none">ITPUB?#37340;浜虹闂?Z,I Pa;o~)t/Tm7L</span><br /> ----------------------------------------<br /> <span style="display: none">L B d-f-A/o*c0</span>NULL<span style="display: none">ITPUB?#37340;浜虹闂?C"}5Q5A#L#t</span><br /> NULL</font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>SQL> SELECT MAX(ID) FROM T;</font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>MAX(ID)<br /> <span style="display: none">!C Cs"Ys5|'`0</span>----------</font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><br /> <span style="display: none">G_S.c d5mk)O#c0</span><font face="瀹?#28003;?>SQL> SELECT AVG(ID) FROM T;</font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>AVG(ID)<span style="display: none">ITPUB?#37340;浜虹闂?O.Ylk0OU(Oy4Dq$vQr</span><br /> ----------</font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><br /> <span style="display: none">RFf+Lf{] y0</span><font face="瀹?#28003;?>SQL> INSERT INTO T VALUES (1);</font></span></p> <p><span style="font-size: 10.5pt"><font face="瀹?#28003;?>宸?#37714;涘缓<span lang="EN-US"> 1 琛?#37510;?/span></font></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;?>?#20187;?#27878;鍑芥暟涓?#23011;旇緝鐗规畩鐨?#37828;?span lang="EN-US">COUNT锛?#32471;?#28051;?#37340;鐗规畩鐐?#37828;疌OUNT?#31497;?#32048;杩?#37733;NULL鍊?#38171;?#37719;?#28003;?#29723;?#28051;病鏈?#29825;?#35120;?#38171;?#37812;?#38000;匔OUNT(COL)涓?#38171;孋OL鍒?#37928;勮褰?#37711;?#28051;篘ULL锛孋OUNT涔熶細杩?#37733;?鍊?#38000;屼笉鏄疦ULL銆?#32471;?#27996;屼釜鐗规畩鐐瑰氨鏄疌OUNT(*)鎴朇OUNT(甯?#38322;?鐨?#35120;?#23534;?#37510;?#26473;欑褰?#23534;?#28003;?#23536;桟OUNT鍙?#28000;?#29825;?#32480;楀?#21613;惈NULL璁?#35120;曞湪鍐?#37928;勮褰?#37804;绘暟銆?/span></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>SQL> SELECT COUNT(*), COUNT(1), COUNT('A'), COUNT(ID), COUNT(NULL) FROM T;</font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>COUNT(*) COUNT(1) COUNT('A') COUNT(ID) COUNT(NULL)<span style="display: none">ITPUB?#37340;浜虹闂?NNOH2z</span><br /> ---------- ---------- ---------- ---------- -----------<br /> <span style="display: none">;s t:O8t3o.y0t0</span> 3 3 3 1 0</font></span></p> <p style="text-indent: 21pt"><span style="font-family: 瀹?#28003;?>鏈鍚庣畝鍗?#29831;?#28051;涓?span lang="EN-US">AVG锛孉VG(COL)绛?#28000;蜂簬SUM(COL)/COUNT(COL)锛屼笉绛?#28000;蜂簬SUM(COL)/COUNT(*)锛?/span></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>SQL> SELECT AVG(ID), SUM(ID)/COUNT(ID), SUM(ID)/COUNT(*) FROM T;</font></span></p> <p><span style="font-size: 10.5pt" lang="EN-US"><font face="瀹?#28003;?>AVG(ID) SUM(ID)/COUNT(ID) SUM(ID)/COUNT(*)<br /> <span style="display: none">6~{9O*mL9C7c)p0</span>---------- ----------------- ----------------<br /> <span style="display: none">6@:[S'L&k\&V9{VR0</span> 1 1 .333333333</font></span></p> <p style="text-indent: 21pt"></p> <p style="text-indent: 21pt"></p> <br /> <img src ="http://www.67529968.com/lingy/aggbug/284559.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2009-06-29 10:59 <a href="http://www.67529968.com/lingy/archive/2009/06/29/284559.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>?#20824;?#24769;鎸夌収DECODE鏉?#28000;?#37833;COUNT?#32053;?#32053;?#32053;http://www.67529968.com/lingy/archive/2009/06/29/284556.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Mon, 29 Jun 2009 02:57:00 GMThttp://www.67529968.com/lingy/archive/2009/06/29/284556.html琛A  
          DW               WP             BJ  
          锛?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;?#38171;? 
          A                 M1             Y  
          B                 M2             N  
          C                 M3             Y  
          D                 M1             Y  
       
      鎴?#37722;?#32513;?#29825;BJ鏄?Y‘鐨凞W鏈?#28598;氬?#25116;釜?#25328;鎬籇W澶氬?#25116;釜?#32053;?#32053;  
        鎴?#37922;COUNT(DW),COUNT(DECODE(A.BJ,'Y',DW,0))  
      杩?#37837;蜂笉琛屽晩?#32053;?#32053;  
      SQL搴旇鎬?#28052;?#37712;?#37727;婏紵?#32053;?#32053;?#31497;瑕?#37922;?#37711;?#28610;?#29831;?#37721;?#38171;?#26473;?#37837;?#28598;?#32515;楀棪浜?闂?#26864;?#37904;规暟锛?0銆佸洖澶嶆?#26271;锛?Top

    1 妤?/a>Visual_Studio_Net锛?#37813;撻紶?#23283;闆?#38171;?input class="user5" title="浜旂骇鐢?#37812;?璇?#37911;?#23536;楀?#21975;皬浜庣瓑浜?000鍒?#38171;?#28598;?#27996;?000鍒? type="button" />鍥?#28598;?#27996;?2006-04-22 20:08:49 寰楀垎 15

    SELECT   COUNT(DW),SUM(DECODE(BJ,'Y',1,0))   FROM   ATop

    2 妤?/a>chliang315锛?#38171;?input class="user3" title="涓夌骇鐢?#37812;?璇?#37911;?#23536;楀?#21975;皬浜庣瓑浜?000鍒?#38171;?#28598;?#27996;?00鍒? type="button" />鍥?#28598;?#27996;?2006-04-22 20:11:32 寰楀垎 35

    鍙?#28000;?#37928;? 
      COUNT(DW),COUNT(DECODE(A.BJ,'Y',DW,null))
    Top

    3 妤?/a>bbcboy锛?#37905;?#37914;?#37725;?#37725;?#38171;?input class="user1" title="涓?#39559;鐢?#37812;?璇?#37911;?#23536;楀?#21975;皬浜庣瓑浜?00鍒? type="button" />鍥?#28598;?#27996;?2006-04-22 20:30:58 寰楀垎 0

    涓?#28003;?#38318;?#37828;?#28610;戒?#21700;晩锛?#38171;? 
      闈?#29999;告劅璋?#38171;?#38171;?nbsp;  
     



    ]]>
    ant+cactus+tomcat5.5瀹?#37731;?#37712;呭崟鍏?#23092;?#29831;?/title><link>http://www.67529968.com/lingy/archive/2009/06/22/283575.html</link><dc:creator>鏋楀厜鐐?/dc:creator><author>鏋楀厜鐐?/author><pubDate>Mon, 22 Jun 2009 07:06:00 GMT</pubDate><guid>http://www.67529968.com/lingy/archive/2009/06/22/283575.html</guid><description><![CDATA[銆涓銆?#28051;嬭浇骞?#29785;?#37720;嬬缉cactus<br /> 銆銆涓嬭浇鍦板潃涓篽ttp://Java.chinaitlab.com/tools/45970.Html 銆?#28751;哻actus鐨刲ib?#27952;褰?#28051;?#37928;刢actus-ant-1.7.1.jar澶?#37714;跺埌ant鐨刲ib?#27952;褰?#37510;?br /> 銆銆浜?#37510;侀?#23943;疆cactus<br /> 銆銆cactus鐨勯?#23943;疆寰堢畝鍗?#38171;?#37826;板缓涓?#37340;cactus.properties鏂?#28000;?#38171;屽?#33333;妸瀹?#37824;惧湪ant鑴?#37832;?#28051;?#37928;刢actus浠诲姟鐨刢lasspath涓?#38171;?#37826;?#28000;?#28051;?#37718;呮嫭濡?#28051;?#37712;呭<br /> 銆銆cactus.sysproperties=cactus.contextURL<br highlighted="1" /> 銆銆#cactus-sample-servlet-cactified灏?#37828;?#28003;?#37928;?#23092;?#29831;曞簲鐢墍?#28266;?#30718;寰?#38171;?080鏄?zmkey style="border-bottom: #ff6c00 2px dotted; float: none; cursor: pointer; font-weight: bold; margin-right: 3px; cssfloat: none" class="zoomino-searchword" offset="52" path="body > div:eq(0) > div:eq(3) > table:eq(2) > tbody:eq(0) > tr:eq(0) > td:eq(0) > div:eq(0) > #content:eq(0) > br:eq(4)" anchorType="previous" jQuery1245654007453="6">绔?#37721;?#37721;?img style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; width: 12px; padding-right: 0px; display: inline; background-position: -18px -23px; float: none; height: 14px; border-top: medium none; border-right: medium none; padding-top: 0px; cssfloat: none" class="zoominoBgImage" src="http://static.zoomino.cn/static-ox/images/blank.gif" width="1" height="1" alt="" /></zmkey><br /> 銆銆cactus.contextURL = http://localhost:8080/cactus-sample-servlet-cactified<br /> 銆銆cactus.servletReDirectorName = ServletRedirector<br /> 銆銆cactus.jspRedirectorName = JspRedirector<br /> 銆銆cactus.filterRedirectorName = FilterRedirector <br /> 銆銆鍏蜂綋鐨勫?#27693;硶?#31912;鍚坅nt鑴?#37832;?#37712;?#26473;?#28051;姝?#29785;噴銆?br /> 銆銆涓?#37510;?#26473;?#29723;宎nt鑴?#37832;?br /> 銆銆 ant鑴?#37832;?#28051;?#29781;?#37813;?#29723;?#28000;?#28051;?#28000;诲姟<br /> 銆銆1銆?#29825;惧畾classpath<br /> 銆銆<path id="project.classpath"><br /> 銆銆 <fileset dir="${lib.dir}"><br /> 銆銆 <include name="*.jar"/><br /> 銆銆 </fileset><br /> 銆銆 <!-- cactus.properties鏂?#28000;?#28751;?#38343;瑕?#37824;惧湪lib.dir?#22669;瀵?#25652;?#37928;勮矾寰?#28051;?--><br /> 銆銆 <pathelement location="${lib.dir}"/><br /> 銆銆 <pathelement location="${tomcat.home}/common/lib/jsp-api.jar"/><br /> 銆銆 <pathelement location="${tomcat.home}/common/lib/servlet-api.jar"/><br /> 銆銆 </path><br /> 銆銆2銆佸畾涔夌浉鍏?#28000;诲姟<br /> 銆銆<taskdef resource="cactus.tasks" classpathref="project.classpath"/><br /> 銆銆 <taskdef name="runservertests" classname="org.apache.cactus.integration.ant.RunServerTestsTask"><br /> 銆銆 <classpath><br /> 銆銆 <path refid="project.classpath"/><br /> 銆銆 </classpath><br /> 銆銆 </taskdef><br /> 銆銆3銆佺紪璇?#25652;?#37922;?#37928;勭被鏂?#28000;跺拰娴?#29831;?#37928;勭被鏂?#28000;?br /> 銆銆4銆?#37813;撳?#21614;暣?#37340;搴?#37922;?#28051;war鏂?#28000;?br /> 銆銆闇瑕?#23049;?#38322;?#37928;?#37828;?#38171;屼笉浠?#29781;?#37813;撳?#21613;簲鐢?#32491;?#38171;?#23092;?#29831;?#32491;?#28052;?#29781;?#37813;撳寘<br /> 銆銆<target name="war" depends="compile.java"<br /> 銆銆 description="Generate the runtime war"><br /> 銆銆 <war warfile="${target.dir}/${project.name}.war"<br /> 銆銆 webXML="${src.webapp.dir}/WEB-INF/web.xml"><br /> 銆銆 <fileset dir="${src.webapp.dir}"><br /> 銆銆 <exclude name="cactus-report.xsl"/><br /> 銆銆 <exclude name="WEB-INF/cactus-web.xml"/><br /> 銆銆 <exclude name="WEB-INF/web.xml"/><br /> 銆銆 </fileset><br /> 銆銆 <classes dir="${target.classes.java.dir}"/><br /> 銆銆 <!-- 鍒繕浜?#37813;撳寘娴?#29831;?#32491;?--><br /> 銆銆 <classes dir="${target.classes.test.dir}"/><br /> 銆銆 <!-- 鍒繕浜?#37813;撳?#21613;?#21229;?#23943;浉鍏?#37928;刯ar鏂?#28000;?--><br /> 銆銆 < lib dir="project.classpath"/><br /> 銆銆 </war><br /> 銆銆 </target><br /> 銆銆5銆佸湪搴?#37922;?#37928;剋eb.xml鏂?#28000;?#28051;?#23075;诲姞娴?#29831;曟墍闇鐨?#37722;勭鏄犲皠<br /> 銆銆cactus鎻愪緵浜?#28051;釜task鏉?#28729;?#37812;?#26473;欎釜宸?#28003;?#38171;孋actifyWar?#25328;WebXmlMerge銆?br /> 銆銆CactifyWar鐨?#37716;熻兘鏄?#38007;姩?#28266;宸?#32513;?#37813;撳寘鐨?#25652;?#37922;?#37928;剋eb.xml鏂?#28000;?#28051;?#23075;诲?#29363;墍闇鐨?#37828;犲皠銆俉ebXmlMerge鏄?#37819;愪緵鍚?#39582;?#28051;釜web.xml鏂?#28000;?#37928;?#37716;熻兘銆?br /> 銆銆<target name="test.prepare"<br /> 銆銆 depends="war, compile.cactus, test.prepare.logging"><br /> 銆銆 <!-- Cactify the web-app archive --><br /> 銆銆 <cactifywar srcfile="${target.dir}/${project.name}.war"<br /> 銆銆 destfile="${tomcat.home}/webapps/${project.name}-cactified.war"<br /> 銆銆 ><br /> 銆銆 <classes dir="${target.classes.java.dir}"/><br /> 銆銆 <classes dir="${target.classes.test.dir}"/><br /> 銆銆 <lib dir="project.classpath"/><br /> 銆銆 </cactifywar><br /> 銆銆</target><br /> 銆銆6銆?#26473;?#29723;?#23092;?#29831;?br /> 銆銆cactus鎻愪緵浜哻actus?#25328;RunServerTests涓釜task鏉?#26473;?#29723;?#23092;?#29831;?#37510;?br highlighted="1" /> 銆銆"cactus" task鏄?#38315;?#26473;?#28598;?#37714;?#28729;?#37731;?#37832;?#37716;?#37731;?#37928;勬渶灏?#37826;?#28000;?#39582;?#26473;?#29723;?#37833;?#26473;?#29723;?#23092;?#29831;?#38171;屽洜姝?#38343;瑕?#37714;跺畾瀹?#37731;?#37832;?#37716;?#37731;?#37928;勭?#35826;瀷锛?#37722;姩閫?#25652;?#32459;?#36423;?#37904;?#38171;?#37721;?#28598;?#38320;嶇疆姣旇緝鏂?#28186;?#38171;?#28003;?#37828;?#37827;犳硶娴?#29831;曡薄tomcat<zmkey style="border-bottom: #ff6c00 2px dotted; float: none; cursor: pointer; font-weight: bold; margin-right: 3px; cssfloat: none" class="zoomino-searchword" offset="84" path="body > div:eq(0) > div:eq(3) > table:eq(2) > tbody:eq(0) > tr:eq(0) > td:eq(0) > div:eq(0) > #content:eq(0) > br:eq(64)" anchorType="previous" jQuery1245654007453="7">杩?#37818;?#23033;?img style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; width: 12px; padding-right: 0px; display: inline; background-position: -18px -23px; float: none; height: 14px; border-top: medium none; border-right: medium none; padding-top: 0px; cssfloat: none" class="zoominoBgImage" src="http://static.zoomino.cn/static-ox/images/blank.gif" width="1" height="1" alt="" /></zmkey>绛?#29863;勬簮銆?#37721;?#28598;栧tomcat5.5鐨勬敮鎸?#28052;熶笉濂?#37510;?br /> 銆銆"RunServerTests"鏄?#38315;?#26473;?#37929;?#37818;?#37722;姩瀹?#37731;?#37832;?#37716;?#29863;?#37833;?#26473;?#29723;?#23092;?#29831;?#38171;屽洜姝?#38315;?#25652;?#32459;嶆參锛?#28051;?#38320;嶇疆杈?#27001;荤儲锛?#28003;嗚兘娴?#29831;?#37722;勭璧勬簮銆?br /> 銆銆<target name="test" depends="test.prepare"<br /> 銆銆 description="Run tests on Tomcat "><br /> 銆銆 <!-- Start the servlet engine, wait for it to be started, run the<br /> 銆銆 unit tests, stop the servlet engine, wait for it to be stopped.<br /> 銆銆 The servlet engine is stopped if the tests fail for any reason --><br /> 銆銆 <!-- 8080鏄?#37832;?#37716;?#37731;?#37928;?#32468;?#37721;?#37721;?#38171;?{project.name}-cactified鏄?#26916;圭洰鐨勮矾寰?#38171;屽拰涓?#28051;姝?#37928;刢actifywar 鐨刣estfile?#27977;瀵?#25652;?--><br /> 銆銆 <runservertests<br /> 銆銆 testURL="http://localhost:8080/${project.name}-cactified/ServletRedirector?Cactus_Service=RUN_TEST"<br /> 銆銆 startTarget="_StartTomcat"<br /> 銆銆 stopTarget="_StopTomcat"<br /> 銆銆 testTarget="_Test"/><br /> 銆銆 </target><br /> 銆銆<!-- _Test灏?#37828;?#28051;?#37340;鏅?#38315;?#37928;刯unit浠诲姟 --><br /> 銆銆 <target name="_Test"><br /> 銆銆 <junit printsummary="yes" fork="yes"><br /> 銆銆 <classpath><br /> 銆銆 <path refid="project.classpath"/><br /> 銆銆 <pathelement location="${target.classes.java.dir}"/><br /> 銆銆 <pathelement location="${target.classes.test.dir}"/><br /> 銆銆 </classpath><br /> 銆銆 <formatter type="brief" usefile="false"/><br /> 銆銆 <formatter type="xml"/><br /> 銆銆 <batchtest><br /> 銆銆 <fileset dir="${src.test.dir}"><br /> 銆銆 <!-- Due to some Cactus synchronization bug, the 'unit' tests need<br /> 銆銆 to run before the 'sample' tests --><br /> 銆銆 <include name="**/Test*.java"/><br /> 銆銆 <exclude name="**/Test*All.java"/><br /> 銆銆 </fileset><br /> 銆銆 </batchtest><br /> 銆銆 </junit><br /> 銆銆 </target><br /> 銆銆鏂?#32468;?#37833;簮: baike.duba.net <img src ="http://www.67529968.com/lingy/aggbug/283575.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.67529968.com/lingy/" target="_blank">鏋楀厜鐐?/a> 2009-06-22 15:06 <a href="http://www.67529968.com/lingy/archive/2009/06/22/283575.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣璇勮</a></div>]]></description></item><item><title>缁檚ervlet鍐?#37719;?#37711;?#23092;?#29831;?#37928;勬荤粨http://www.67529968.com/lingy/archive/2009/06/22/283551.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Mon, 22 Jun 2009 05:39:00 GMThttp://www.67529968.com/lingy/archive/2009/06/22/283551.html 缁檚ervlet鍐?#37719;?#37711;?#23092;?#29831;?#37928;勬荤粨鏀惰棌
    servlet鐨?#23092;?#29831;?#28051;鑸?#37833;?#29831;?#38343;瑕?#28729;?#37731;?#37928;勬敮鎸?#38171;屼笉鏄?#37709;?#38315;?#29999;?#37928;刯ava绫?#37928;刯unit娴?#29831;?#28051;鏍风畝鍗?#38171;?br />  
    涓嬮潰閫?#26473;囧?#31547;elloWorld浠?#37934;?#37928;?#23092;?#29831;?#38339;?#26473;?#27996;?#37713;犵servlet娴?#29831;?#37826;规硶銆?br />  
    琚?#23092;?#29831;?#37928;HelloWorld绫?#37928;?#28000;?#37934;?#28641;?#28051;?#38171;?br />  
    /**
     * 琚?#23092;?#29831;?#37928;剆ervlet
     */

    import java.io.IOException;
     
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.cactus.WebRequest;
    import org.apache.cactus.server.HttpServletRequestWrapper;
     
    public class HelloWorld extends HttpServlet{
     
     public void saveToSession(HttpServletRequest request) {

             request.getSession().setAttribute("testAttribute",request.getParameter("testparam"));

     }
     
     public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException{

             String username=request.getParameter("username");

             response.getWriter().write(username+":Hello World!");
           
     }
     
     public boolean authenticate(){
            
            return true;
     
     }

    }
     
    浠HelloWorld涓?#28186;?#38171;?#37812;戞荤粨浜哠ervlet鐨?#28598;氱娴?#29831;?#37826;规硶濡?#28051;?#38171;?br />  
    涓.浣?#37922;HttpUnit娴?#29831;?br />  
    import com.meterware.httpunit.GetMethodWebRequest;
    import com.meterware.httpunit.WebRequest;
    import com.meterware.httpunit.WebResponse;
    import com.meterware.servletunit.InvocationContext;
    import com.meterware.servletunit.ServletRunner;
    import com.meterware.servletunit.ServletUnitClient;
    import junit.framework.Assert;
    import junit.framework.TestCase;
     
    public class HttpUnitTestHelloWorld extends TestCase {
     
     protected void setUp() throws Exception {
      super.setUp();
     }
     
     protected void tearDown() throws Exception {
      super.tearDown();
     }
     
     public void testHelloWorld() {
     
      try {

       // 鍒涘缓Servlet鐨勮繍琛?#37916;?#28583;?/p>

       ServletRunner sr = new ServletRunner();

       // 鍚?#37916;?#28583;?#28051;?#23049;?#37712;孲ervlet

       sr.registerServlet("HelloWorld", HelloWorld.class.getName());
     
       // 鍒涘缓璁?#38338;Servlet鐨?#28729;?#37812;?#32468;?/p>

       ServletUnitClient sc = sr.newClient();

       // 鍙戦?#29831;锋眰

       WebRequest request = new GetMethodWebRequest("http://localhost/HelloWorld");
       request.setParameter("username", "testuser");

       InvocationContext ic = sc.newInvocation(request);

       HelloWorld is = (HelloWorld) ic.getServlet();
     
       // 娴?#29831;晄ervlet鐨勬?#24874;釜鏂规硶

       Assert.assertTrue(is.authenticate());

       // 鑾?#23536;楁?#23257;鏈?#37716;?#37731;?#37928;?#28103;?#37805;?/p>

       WebResponse response = sc.getResponse(request);

       // 鏂?#29815;

       Assert.assertTrue(response.getText().equals("testuser:Hello World!"));

      } catch (Exception e) {

       e.printStackTrace();

      }

     }
     
    }
     
    涓?#26473;?#28186;?#28699;?#37711;?#28729;?#37828;痡unit鐨?#28051;?#37340;娴?#29831;?#28186;?#28699;?#38171;屽湪鍏?#28051;?#28003;?#37922;?#27996;httpunit妯嫙鐨剆ervlet鐜?#28583;?浣?#37922;?#28051;?#26473;?#37826;规硶娴?#29831;?br />  
    servlet鍙?#28000;?#38004;辩?#35826;鍣?#38171;屽鏄撴妸璇?#23092;?#29831;?#37712;欏叆ant鎴杕aven鑴?#37832;?#38171;?#29825;?#23092;?#29831;?#26473;?#29723;?#37510;?br />  
    httpunit?#32137;?#28483;锛歨ttp://httpunit.sourceforge.net/
     
    浣?#37922;?#29831;?#32457;?#37826;规硶娴?#29831;?#37928;?#23534;?#37904;瑰氨鏄?#38171;?#28641;?#37835;?#29781;?#28003;?#37922;request(response)鐨剆etCharercterEncoding鏂规硶?#26882;锛?#23092;?#29831;曚細鍑?#37916;?#28051;浜?#38338;?#26864;?
     
    鑰?#28051;httpunit?#28266;娴?#29831;晄ervlet琛?#28051;烘椂锛岄噰鐢?#37928;?#37828;?#28729;?#37711;?#22959;嫙娴?#29785;?#37731;?#38171;?#37832;夋椂娴?#29831;?#23011;旇緝闅?#37712;?#37510;?br />  
    浜?浣?#37922;cactus娴?#29831;?br />  
    /**
     * cactus娴?#29831;晄ervlet鐨勪緥瀛?br />  * 蹇?#26916;?#29781;?#37832;塼omcat鐨勬敮鎸?br />  *
     */
     
    import junit.framework.Test;
    import junit.framework.TestSuite;
    import org.apache.cactus.ServletTestCase;
    import org.apache.cactus.WebRequest;
    import org.apache.cactus.WebResponse;
    public class CactusHelloWorld extends ServletTestCase{
     
         HelloWorld servlet;
         public CactusHelloWorld(String theName) {
             super(theName);
         }
     
         protected void setUp() throws Exception {
             super.setUp();
             servlet = new HelloWorld();
         }
     
         protected void tearDown() throws Exception {
             super.tearDown();
         }
     
         /**
          * 娴?#29831;?#37826;规硶娴?#29831;?#37721;傛暟?#28266;姝?#29825;?#32515;?br />       *
          * @param webrequest
          */
     
         public void beginSaveToSessionOK(WebRequest request) {
             request.addParameter("testparam", "it works!");
         }
        
         /**
          * 娴?#29831;?#37826;规硶娴?#29831;?#37721;傛暟?#28266;姝?#29825;?#32515;?br />       *
          * @param webrequest
          */
     
         public void beginDoGet(WebRequest request) {
             request.addParameter("username", "testuser");
         }
     
         /**
          * ?#30367;鐢servlet鐨?#23092;?#29831;?#37826;规硶
          * 
          */

         public void testSaveToSessionOK() {
             servlet.saveToSession(request);
             assertEquals("it works!", session.getAttribute("testAttribute"));
         }
     
         public void testDoGet() {
             try {
                 servlet.doGet(request, response);
             } catch (Exception e) {
                 e.printStackTrace();
             }
         }
     
         /**
          * 姝?#37826;规硶鍙?#28000;?#37714;?#37826;?#23092;?#29831;?#37826;规硶鐨勮緭鍑?#38171;屼細浼?#38315;?#23092;?#29831;?#37826;规硶鐨剅eponse缁檈nd***,骞?#28051;?#37837;?#23534;?#37718;?#28051;篶actus
          * 鐨刉ebResponse鎴?#38000;?#37721;?#28000;?#29882;httpunit?#27878;鎴?#38171;?#37837;?#23534;?#37718;?#28051;篽ttpunit鐨剅esponse
          *
          * @param response
          */

         public void endDoGet(WebResponse response) {
             String content;        
             content = response.getText();
             assertEquals("testuser:Hello World!", content);
         }
    }
     
    cactus鍏?#28598;?#28051;?#28725;岀伒娲?#37928;?#23092;?#29831;曞姛?#20824;锛?#28641;?#29781;?#23092;?#29831;doGet鏂规硶锛?#37714;?#28051;篵eginDoGet(妯嫙娴?#29831;?#37721;傛?#25292;缃?銆丏oGet(鎵?#29723;?#23092;?#29831;?銆乪ndDoGet(鐘?#37804;佺粨鏋滈獙璇?
     
    ?#27977;姣httpunit鏉?#29831;?#38171;?#37712;?#23092;?#29831;?#37831;?#28051;?#28729;?#37828;?#38171;?#23092;?#29831;晄ervlet鏇?#28051;?#28051;?#28051;?娴佺鏇?#28051;烘?#21614;櫚锛?#28003;?#37828;痗actus闇瑕?#28729;?#37731;?#37824;?#37816;?#38171;?#28003;?#23536;?#23092;?#29831;曚笉鍙?#28000;?#38007;姩杩?#29723;?#38171;?#28003;?#37828;?br />  
    濡?#37835;?#28003;?#37922;?#28051;?#37340;宓屽叆寮?#37928;?#28729;?#37731;?#38171;?#23092;?#29831;曞氨鍙?#28000;?#38007;姩浜?#37510;?br />  
    cactus鏄?#28051;?#37340;servlet?#25328;jsp鐨?#23092;?#29831;曟鏋?http://jakarta.apache.org/cactus/getting_started.html
     
    涓?浣?#37922;Jetty浣?#28051;哄?#23677;叆寮?#28729;?#37731;?#23092;?#29831;晄ervlet.
     
    /**
     * 涓?#37340;鍏?#27996;庡?#23677;叆寮jetty娴?#29831;?#37928;勪緥瀛?#38171;宩etty浣?#28051;簊tubs鐨?#28051;?#37340;渚?#28699;?br />  *
     */
    package com.easyjf.testexample;
     
    import org.mortbay.jetty.Connector;
    import org.mortbay.jetty.Server;
    import org.mortbay.jetty.bio.SocketConnector;
    import org.mortbay.jetty.servlet.ServletHandler;
     
    import com.meterware.httpunit.WebClient;
    import com.meterware.httpunit.WebConversation;
    import com.meterware.httpunit.WebResponse;
     
    import junit.framework.Assert;
    import junit.framework.TestCase;
     
    public class JettySampleTest extends TestCase {
     
     Server server;
     protected void setUp() throws Exception {
          //閫?#26473;?#28000;?#37934;?#29825;?#32515;?#39582;?#37722;姩涓?#37340;鏈?#37716;?#37731;?#38171;?#29831;?#37832;?#37716;?#37731;?#37828;痵ervlet鐨?#23092;?#29831;曞鍣?br />       super.setUp();
          server = new Server();
          Connector connector=new SocketConnector();
          connector.setPort(80);
          server.setConnectors(new Connector[]{connector});
          ServletHandler handler=new ServletHandler();
          server.setHandler(handler);
          handler.addServletWithMapping("HelloWorld", "/");
          server.start();
     }
     
     protected void tearDown() throws Exception {
      super.tearDown();
      server.stop();
     }
     
     public void testHellWorld() {
      try {
       WebConversation wc = new WebConversation();
       WebResponse web = wc.getResponse("http://127.0.0.1/HelloWorld");
       String result=web.getText();
       Assert.assertEquals(result,"it works!");
      } catch (Exception e) {
       e.printStackTrace();
      }
     }
    }
     
    鍙?#28000;?#37721;?#37916;?#38171;宩etty鍙?#28000;?#37711;呭綋涓?#37340;servlet鐨?#28729;?#37731;?#38171;?#37826;?#28186;?#37928;?#37828;?jetty鏀?#37816;佸?#23677;叆寮?#37832;?#37716;?#38171;?#37719;?#37721;?#28000;?#38315;?#26473;?#28000;?#37934;?#37833;?#37722;姩锛?br />  
    ?#22669;浠?#29781;?#37712;欒嚜?#23017;娴?#29831;?#37928;勪緥瀛?#23536;?#37826;?#28186;?#38171;?#37721;?#28000;粨鍚坔ttpunit鎴?#38000;卌actus杩?#29723;宻ervlet娴?#29831;?#37510;?br />  
    jetty涓?#26916;?#38171;歨ttp://docs.codehaus.org/display/JETTY/Embedding+Jetty


    ?#27923; 浣?#37922;mock瀵硅薄锛屾澶?#28003;?#37922;easymock
     
    import java.io.PrintWriter;
    import java.io.Writer;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import junit.framework.Assert;
    import junit.framework.TestCase;
    import static org.easymock.EasyMock.*;
    public class MockTestServlet extends TestCase {
     
        public void testService() throws Exception {

            System.out.println("service");

            HttpServletRequest request = createMock(HttpServletRequest.class);

            HttpServletResponse response = createMock(HttpServletResponse.class);

            //Creating the ServletConfig mock here

            ServletConfig servletConfig = createMock(ServletConfig.class);

            //Creating the ServletContext mock here

            ServletContext servletContext = createMock(ServletContext.class);
           
            //Create the target object 
         
            HelloWorld4 instance = new HelloWorld();

            //鍒?#28654;嬪寲servlet,涓鑸?#37922;?#28729;?#37731;?#37813;挎媴锛?#28051;鑸皟鐢servletConfig浣?#28051;?#37721;傛暟鍒?#28654;嬪寲锛屾澶勬?#23257;瀹?#37731;?#29723;?#28051;?/p>

            instance.init(servletConfig);
     
            //?#28266;鏌愪簺鏂规硶琚皟鐢椂璁?#32515;?#37832;?#37832;?#37928;勮繑鍥?#37706;?#38171;?#28641;?#28051;嬭繖鏍峰氨?#31497;?#32048;鍘诲疄闄呰皟鐢servletConfig鐨刧etServletContext鏂规硶锛岃?#37828;?#37929;?#37818;?#26473;?#37733;?br />  
            //servletContext,鐢?#27996;巗ervletConfig鏄痬ock鍑?#37833;?#37928;?#38171;屾墍浠?#37721;?#28000;?#28729;?#37711;?#37818;?#37714;?#37510;?/p>

            expect(servletConfig.getServletContext()).andReturn(servletContext).anyTimes();

            expect(request.getParameter("username")).andReturn("testuser");

            PrintWriter pw=new PrintWriter(System.out,true);

            expect(response.getWriter()).andReturn(pw).anyTimes();
           
            //浠?#28051;婂潎鏄?#35120;?#37714;?#38171;?#28051;嬮潰涓?#38322;嶆斁锛?#29831;?#32457;?#37832;?#37714;?#28051;easymock娴?#29831;?#37832;?#37714;?#38171;?#29781;佺悊瑙?#29831;风湅easymock娴?#29831;?#37928;?#28051;浜?#29863;勬枡
            replay(request);
            replay(response);
            replay(servletConfig);
            replay(servletContext);
     
            instance.doGet(request, response);

            pw.flush();
           
     
            //楠?#29831;佺粨鏋?#37828;惁棰勬湡锛?#28641;?#37835;?#26864;勬湡锛?#37714;欎細?#28266;pw涓?#37712;?#37713;簍estuser.
            verify(request);
            verify(response);
            verify(servletConfig);
            verify(servletContext);
       }
    }
     
    mock娴?#29831;?#23049;?#38322;?#29723;?#28051;?#38171;宮ock瀵硅薄鍏?#28729;?#38318;?#37828;?#22959;嫙鐨?#28725;硅薄锛?#37826;规硶涓鑸?#37929;?#37818;?#32513;?#37713;?#28051;?#37340;杩?#37733;?#37706;?#38171;屾病鏈夊?#34562;綋鐨?#28725;硅薄閫?#26440;?#38171;宮ock瀵硅薄
     
    鏄?#37922;?#37833;?#29999;?#37716;?#23092;?#29831;曡娴?#29831;?#37928;勭被鐨?#37510;?#23011;?#28641;?#29781;?#23092;?#29831;晄ervlet鐨?#37712;?#38318;?#29723;?#28051;?#38171;?#37721;堜笉鎯?#29781;?#28729;?#37731;?#32475;?#37916;?#28583;?#38171;屽氨鍙?#28000;?#38322;?#37922;mock娴?#29831;?#37510;?br />  
    easymock鏄痬ock娴?#29831;?#37928;?#28051;?#37340;妗?#37835;?#38171;歨ttp://www.easymock.org/
     
    鍙戣浜?@ 2007骞?2鏈?0鏃?22:13:00|璇勮(2)

    鏂?#28051;?#30226;: 璁?#29825;?#22959;?#23534;忎箣鍒涘?#28888;寮?| 鏃?#28051;?#30226;: 鏈?#37716;畾浣?#37731;?#22959;?#23534;?service locator)wldandanpig 鍙戣浜?007骞?鏈?4鏃?10:09:40  IP:涓炬姤
    璇?#38338;?#22948;?#28051;?br /> public String saveInfo()
    {
    String reqInfo = request.getParameter("reqInfo");
    String sessInfo = (String)request.getSession().getAttribute("sessInfo");

    request.setAttribute("reqInfo" , "response:"+reqInfo);
    request.getSession().setAttribute("sessInfo", "response:"+reqInfo);

    return "SUCCESS";
    }
    杩欎釜鏂规硶鎬?#28052;?#23092;?#29831;曞晩cz_hyf 鍙戣浜?007骞?鏈?4鏃?17:20:23  IP:涓炬姤
    濡?#37835;?#37922;httpunit鐨?#29831;?/p>

    public void testHelloWorld() {

    try {

    // 鍒涘缓Servlet鐨勮繍琛?#37916;?#28583;?/p>

    ServletRunner sr = new ServletRunner();

    // 鍚?#37916;?#28583;?#28051;?#23049;?#37712;孲ervlet

    sr.registerServlet("HelloWorld", HelloWorld.class.getName());

    // 鍒涘缓璁?#38338;Servlet鐨?#28729;?#37812;?#32468;?/p>

    ServletUnitClient sc = sr.newClient();

    // 鍙戦?#29831;锋眰

    WebRequest request = new GetMethodWebRequest("http://localhost/HelloWorld");
    request.setParameter("reqInfo", "......");

    InvocationContext ic = sc.newInvocation(request);

    HelloWorld is = (HelloWorld) ic.getServlet();

    // 娴?#29831;晄ervlet鐨勬?#24874;釜鏂规硶

    Assert.assertEquals(is.saveInfo,"SUCCESS");

    } catch (Exception e) {

    e.printStackTrace();

    }

    }

    濡?#37835;?#26473;樹笉鏀惧績锛屼笉濡妸request?#25328;request.session涓?#37928;?#37706;?#37721;?#37713;?#37833;湅?#28229;鏄惁鏄?#28003;?#37824;?#26473;涘幓鐨?/p>


    鏈?#37826;?#37833;?#38007;狢SDN鍗?#28729;?#38171;岃浆杞?#29831;?#37837;?#37828;?#37713;?#28598;?#38171;歨ttp://blog.csdn.net/cz_hyf/archive/2007/02/10/1507211.aspx



    ]]>
    oracle trunc()鍑芥暟鐨?#37922;硶http://www.67529968.com/lingy/archive/2009/06/19/283162.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Fri, 19 Jun 2009 01:39:00 GMThttp://www.67529968.com/lingy/archive/2009/06/19/283162.htmlTRUNC()鍑芥暩鍒?#37711;?#32459;?img src="http://blog.csdn.net/Emoticons/tongue_smile.gif" alt="" />

    1.TRUNC(for dates)
            TRUNC鍑芥暟涓?#37816;囧畾鍏冪礌鑰?#37812;?#37720;?#37928;勬棩鏈?#37706;?#37510;?br />         鍏?#37711;蜂綋鐨?#29831;硶鏍?#23534;?#28641;?#28051;?#38171;?br />         TRUNC锛坉ate[,fmt]锛?br />         鍏?#28051;?#38171;?br />         date        涓?#37340;鏃?#37832;?#37706;?br />         fmt                鏃?#37832;?#37837;?#23534;?#38171;?#29831;?#37827;?#37832;?#28751;?#37922;?#37816;囧畾鐨?#37711;冪礌鏍?#23534;忔墍鎴?#37720;?#37510;傚?#30028;暐瀹?#37714;?#37922;?#37832;杩?#37928;勬棩鏈?#37812;?#37720;?br />         涓嬮潰鏄?#29831;?#37713;芥暟鐨?#28003;?#37922;?#37807;呭喌锛?br />         TRUNC锛圱O_DATE(’24-Nov-1999 08:00 pm’,’dd-mon-yyyy hh:mi am’)锛?br />                 =’24-Nov-1999 12:00:00 am’
            TRUNC锛圱O_DATE(’24-Nov-1999 08:37 pm’,’dd-mon-yyyy hh:mi am’,’hh’)锛?nbsp;       =’24-Nov-1999 08:00:00 am’

    2.TRUNC(for number)
            TRUNC鍑芥暟杩?#37733;?#28598;勭悊鍚?#37928;勬暟鍊?#38171;?#37711;跺伐浣?#37832;?#37714;?#28051;ROUND鍑芥暟鏋?#28051;虹被浼?#38171;?#37721;?#37828;?#29831;?#37713;芥暟?#31497;瀵规?#22247;畾灏忔暟鍓?#37812;?#37722;?#37928;?#38318;?#37714;嗗?#27697;浉搴旇?#23941;叆閫夋嫨澶勭悊锛岃?#32513;?#32513;?#37812;?#37720;?#37510;?br />         鍏?#37711;蜂綋鐨?#29831;硶鏍?#23534;?#28641;?#28051;?br />         TRUNC锛坣umber[,decimals]锛?br />         鍏?#28051;?#38171;?br />         number        寰呭仛鎴?#37721;?#28598;勭悊鐨勬暟鍊?br />         decimals        鎸?#37828;?#38343;淇濈暀灏忔暟鐐?#37722;庨潰鐨?#28003;嶆暟銆?#37721;?#38315;?#26916;?#38171;屽?#30028;暐瀹?#37714;?#37812;?#37720;绘墍鏈?#37928;勫?#24532;暟閮?#37714;?br />         涓嬮潰鏄?#29831;?#37713;芥暟鐨?#28003;?#37922;?#37807;呭喌锛?br />         TRUNC锛?9.985锛?锛?89.98
            TRUNC锛?9.985锛?89
            TRUNC锛?9.985锛?1锛?80
            娉剰锛?#32471;?#27996;屼釜鍙傛暟鍙?#28000;?#28051;?#29840;熸暟锛?#29723;?#32448;?#28051;?#28751;忔暟鐐瑰杈规?#22247;畾浣嶆暟鍚庨潰鐨?#38318;?#37714;?#37812;?#37720;?#38171;?#37719;冲潎浠?璁?#37510;?


    ]]>
    oracle merge into 鐨?#37922;硶璇?#29785;?瀹炰緥 http://www.67529968.com/lingy/archive/2009/06/18/283070.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Thu, 18 Jun 2009 08:10:00 GMThttp://www.67529968.com/lingy/archive/2009/06/18/283070.htmloracle merge into 鐨?#37922;硶璇?#29785;?瀹炰緥
    oracle merge into 鐨?#37922;硶璇?#29785;?瀹炰緥

    浣?#37922;?#38171;歮erge into 瑙喅鐢B琛?#29882;?#37826;癆琛暟鎹?#38171;?#28641;?#37835;A琛?#28051;病鏈?#38171;?#37714;欐妸B琛?#37928;勬暟鎹?#37819;掑叆A琛?#38171;?/p>

    璇硶锛?/p>

    MERGE INTO [your table-name] [rename your table here]

    USING ( [write your query here] )[rename your query-sql and using just like a table]

    ON ([conditional expression here] AND [...]...)

    WHEN MATHED THEN [here you can execute some update sql or something else ]

    WHEN NOT MATHED THEN [execute something else here ! ]

    -------------------------------------瀹炰緥-----------------------------------------------------------------

    merge into tfa_alarm_act_nms a
    using (select FP0,FP1,FP2,FP3,REDEFINE_SEVERITY
    from tfa_alarm_status) b
    on (a.fp0=b.fp0 and a.fp1=b.fp1 and a.fp2=b.fp2 and a.fp3=b.fp3)
    when matched then update set a.redefine_severity=b.redefine_severity
    when not matched then insert (a.fp0,a.fp1,a.fp2,a.fp3,a.org_severity,a.redefine_severity,a.event_time
    ,a.int_id)
    values (b.fp0,b.fp1,b.fp2,b.fp3,b.REDEFINE_SEVERITY,b.redefine_severity,sysdate,7777778);

    浣?#37922;?#38171;?#37714;?#37922;?#29723;?font color="#0000ff"> tfa_alarm_status璺?#37826;拌tfa_alarm_act_nms 鐨刡.redefine_severity锛?/font>鏉?#28000;?#37828;?font color="#0000ff">a.fp0=b.fp0 and a.fp1=b.fp1 and a.fp2=b.fp2 and a.fp3=b.fp3锛?/font>濡?#37835;?font color="#0000ff">tfa_alarm_act_nms琛?#28051;病鏈?#29831;?#37833;?#28000;?#37928;勬暟鎹?#28751;?#37819;掑叆銆?/font>

    濡?#37835;?#28003;?#37928;勬暟鎹?#38322;?#23536;?#28598;?#38171;屾sql鏁?#37916;?#38344;?#29999;搁珮銆?/p>



    ]]>瑙?#37835;?#38171;?#37804;?#37837;蜂娇鐢Oracle鐨凞ECODE()鍑芥暟 http://www.67529968.com/lingy/archive/2009/06/18/283067.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Thu, 18 Jun 2009 08:08:00 GMThttp://www.67529968.com/lingy/archive/2009/06/18/283067.html 

    DECODE()鍑芥暟锛屽畠灏?#26440;撳叆?#26271;鍊?#28051;?#37713;芥暟涓?#37928;?#37721;傛暟鍒?#29723;浉姣旇緝锛?#37837;规嵁杈撳叆鍊?#26473;?#37733;?#28051;?#37340;瀵?#25652;?#37706;?#37510;?#37713;芥暟鐨?#37721;傛暟鍒?#29723;?#37828;?#37922;辫嫢骞叉暟鍊?#37721;?#37711;?#28725;?#25652;旂粨鏋?#37706;?#32513;勬垚鐨勮嫢骞?#25652;忓伓褰?#23534;?#37510;?#35120;撶劧锛?#28641;?#37835;?#37832;兘涓?#28000;?#28003;?#28051;?#37340;瀹?#37721;?#25652;忓伓鍖归厤鎴?#37716;?#38171;?#37714;?#37713;芥暟涔?#37832;?#27035;樿鐨勮繑鍥?#37706;?#37510;?

    鍖?#37714;?#27996;嶴QL鐨?#37711;?#28729;?#37713;芥暟锛孌ECODE鍑芥暟杩樿兘璇?#37714;拰鎿?#28003;滅鍊?#37510;?

    璇硶锛欴ECODE(control_value,value1,result1[,value2,result2…][,default_result]);

    control _value璇曞浘澶勭悊鐨勬暟鍊?#37510;侱ECODE鍑芥暟灏?#29831;暟鍊?#28051;?#37722;庨潰鐨?#28051;绯?#37714;?#37928;勫伓搴忕浉姣旇緝锛?#28000;喅?#30078;杩?#37733;?#37706;?#37510;?

    value1鏄?#28051;缁勬垚搴忓伓鐨勬暟鍊?#37510;?#28641;?#37835;?#26440;撳叆?#26271;鍊?#28051;?#28052;嬪尮?#21412;鎴?#37716;?#38171;?#37714;欑浉搴?#37928;勭粨鏋?#28751;?#29722;?#26473;?#37733;?#37510;?#28725;?#25652;?#28051;?#37340;绌?#37928;勮繑鍥?#37706;?#38171;?#37721;?#28000;?#28003;?#37922;?#37711;抽敭瀛桸ULL浜?#28052;?#28725;?#25652;?

    result1 鏄?#28051;缁勬垚搴忓伓鐨勭粨鏋?#37706;?#37510;?

    default_result 鏈兘涓?#28000;?#28003;?#28051;?#37340;鍊?#37718;?#38320;嶆椂锛?#37713;芥暟杩?#37733;?#37928;勯?#27199;鍊?#37510;?

    渚?#28641;?#38171;?

    selectdecode( x , 1 , ‘x is 1 ’, 2 , ‘x is 2 ’, ‘others’) from dual

    褰搙绛?#27996;??#26882;锛?#37714;?#26473;?#37733;?#8216;x is 1’銆?

    褰搙绛?#27996;??#26882;锛?#37714;?#26473;?#37733;?#8216;x is 2’銆?

    ?#24769;鍒?#38171;?#26473;?#37733;瀘thers’銆?

    闇瑕?#38171;?#23011;旇緝2?#37340;鍊?#37928;勬椂鍊?#38171;?#37721;?#28000;厤鍚SIGN()鍑芥暟涓璧蜂娇鐢?#37510;?

    SELECT DECODE( SIGN(5 -6), 1 'Is Positive', -1, 'Is Nagative', 'Is Zero')

    鍚?#37837;?#38171;屼篃鍙?#28000;?#37922;CASE瀹?#37916;?#38171;?

    SELECT CASE SIGN(5 - 6)
                WHEN  1  THEN  'Is Positive'
                WHEN銆-1 THEN  'Is Nagative'
                ELSE銆'Is Zero' END
                FROM DUAL

    姝?#28598;?#38171;?#26473;?#37721;?#28000;湪Order by涓?#28003;?#37922;Decode銆?

    渚?#28641;?#38171;?#29723;table_subject锛?#37832;subject_name鍒?#37510;?#29781;佹眰鎸夌収锛?#29831;?#37510;佹暟銆?#28598;?#37928;?#26916;?#25652;?#26473;?#29723;?#37818;?#25652;?#37510;?#26473;欐椂锛屽氨鍙?#28000;?#38344;?#29999;歌交鏉?#37928;?#28003;?#37922;Decode瀹?#37812;?#29781;佹?#20633;簡銆?

    select * from table_subject order by decode(subject_name, '璇?#37826;?, 1, '?#26271;瀛?, 2, , '澶?#29831;?,3)锛?#29840;?#28000;荤紪杈?#38171;氬崲鍏?#37835;?#38171;?



    ]]>
    鎬?#37837;蜂粠涓?#37340;杩?#32459;嬭繑鍥?#28051;?#37340;?#31912;鏋滈泦http://www.67529968.com/lingy/archive/2009/06/18/283045.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Thu, 18 Jun 2009 06:22:00 GMThttp://www.67529968.com/lingy/archive/2009/06/18/283045.htmlcreate or replace procedure p_stu_lst(result out sys_refcursor) is
    BEGIN
       OPEN RESULT FOR SELECT * FROM test;
    end p_stu_lst;
    SQL> select * from test;

    NAME       KM                 CJ
    ---------- ---------- ----------
    寮?#28051;?nbsp;      璇?#37826;?nbsp;              80
    寮?#28051;?nbsp;      ?#26271;瀛?nbsp;              86
    寮?#28051;?nbsp;      ?#23283;璇?nbsp;              75
    鏉庡洓       璇?#37826;?nbsp;              78
    鏉庡洓       ?#26271;瀛?nbsp;              85
    鏉庡洓       ?#23283;璇?nbsp;              78
    鏉庡洓       鐗?#37918;?nbsp;              90

    宸?#38315;夋嫨7琛?#37510;?br />
    SQL> exec p_stu_lst(:aaa);

    PL/SQL 杩?#32459;嬪凡鎴?#37716;?#28729;?#37812;?#37510;?br />
    SQL> print aaa

    NAME       KM                 CJ
    ---------- ---------- ----------
    寮?#28051;?nbsp;      璇?#37826;?nbsp;              80
    寮?#28051;?nbsp;      ?#26271;瀛?nbsp;              86
    寮?#28051;?nbsp;      ?#23283;璇?nbsp;              75
    鏉庡洓       璇?#37826;?nbsp;              78
    鏉庡洓       ?#26271;瀛?nbsp;              85
    鏉庡洓       ?#23283;璇?nbsp;              78
    鏉庡洓       鐗?#37918;?nbsp;              90

    宸?#38315;夋嫨7琛?#37510;?/div>

    ]]>
    Oracle PL/SQL?#29238;鏍?#37928;?#28699;範http://www.67529968.com/lingy/archive/2009/06/18/283042.html鏋楀厜鐐?/dc:creator>鏋楀厜鐐?/author>Thu, 18 Jun 2009 06:11:00 GMThttp://www.67529968.com/lingy/archive/2009/06/18/283042.html琚?#26473;囨护骞?#37723;?/a>
    涓 ?#29238;鏍?#37828;?#28000;涔?/strong>

    ?#29238;鏍?#28699;楅潰鐞?#29785;?#28751;?#37828;父?#23017;鐨勫厜鏍?#37510;?

    鐢暟鎹?#25652;?#29831;?#29815;鏉?#37819;?#26473;?#38171;氭父鏍?#37828;?#37828;犲?#21227;湪?#31912;鏋滈泦涓?#28051;琛屾暟鎹?#28051;?#37928;?#28003;嶇疆瀹?#28003;?#38171;?#37832;?#27996;嗘父鏍?#38171;?#37922;?#37812;峰氨鍙?#28000;?#29825;?#38338;粨鏋滈泦涓?#37928;?#28000;绘剰涓琛屾暟鎹?#27996;?#38171;屽?#21976;父鏍?#37824;?#32515;埌鏌?#29723;?#37722;?#38171;?#37719;?#37721;?#28725;?#29831;?#29723;屾暟鎹?#26473;?#29723;屾搷浣?#38171;?#28186;?#28641;?#37819;?#37721;栧?#25779;墠琛?#37928;勬暟鎹?#32475;?#37510;?

    浜??#29238;鏍?#37928;?#37714;?#32491;?/strong>

    鏄?#23534;忔父鏍囧?#23684;殣寮忔父鏍?

    鏄?#23534;忔父鏍?#37928;?#28003;?#37922;?#38343;瑕?姝?#38171;?

    1. 澹?#37828;庢父鏍?

    CURSOR mycur(vartype number) is
                select emp_no,emp_zc from cus_emp_basic
                where com_no = vartype;


    2. 鎵撳紑?#29238;鏍?

    open mycur(000627)

    娉?#38171;?00627鏄?#37721;傛暟

    3. 璇?#37721;栨暟鎹?

    fetch mycur into varno, varprice;

    4. 鍏?#38338;父鏍?

    close mycur;

    涓??#29238;鏍?#37928;?#28766;?#37804;?/strong>

    oracle ?#29238;鏍?#37832;??#37340;灞?#37804;?#38171;?ISOPEN锛?FOUND锛?NOTFOUND锛?ROWCOUNT銆?

    %ISOPEN鍒?#37826;父鏍?#37828;惁琚?#37813;撳紑锛?#28641;?#37835;?#37813;撳紑%ISOPEN绛?#27996;巘rue,?#24769;鍒?#32475;?#27996;巉alse锛?

    %FOUND %NOTFOUND鍒?#37826;父鏍囨墍?#28266;鐨勮鏄惁鏈?#37825;?#38171;?#28641;?#37835;?#37832;?#37825;?#38171;?#37714;?FOUNDD绛?#27996;巘rue锛屽惁鍒?#32475;?#27996;巉alse锛?

    %ROWCOUNT杩?#37733;?#35120;撳墠浣嶇疆涓?#23005;父鏍?#29831;?#37721;?#37928;勮褰曡?#23678;暟銆?

    ?#27923; 绀?#28186;?/strong>

    set serveroutput on;
                declare
                varno varchar2(20);
                varprice varchar2(20);
                CURSOR mycur(vartype number) is
                select emp_no,emp_zc from cus_emp_basic
                where com_no = vartype;
                begin
                if mycur%isopen = false then
                open mycur(000627);
                end if;
                fetch mycur into varno,varprice;
                while mycur%found
                loop
                dbms_output.put_line(varno||','||varprice);
                if mycur%rowcount=2 then
                exit;
                end if;
                fetch mycur into varno,varprice;
                end loop;
                close mycur;
                end;


    PL/SQL璁?#35120;?#37928;勭粨鏋勫拰C璇?#29815;涓?#37928;勭粨鏋?#28003;?#32491;?#28028;?#38171;?#37828;?#37922;?#28051;缁勬暟鎹?#26916;?#37835;勬垚鐨勯?#26440;?#37719;?#37711;?#37510;?

    PL/SQL璁?#35120;曞?#26421;笉淇?#28699;樺湪?#26271;鎹?#25652;?#28051;?#38171;屽畠涓?#37721;?#38322;?#28051;鏍?#38171;?#28103;?#28699;樺湪鍐?#28699;樼闂?#28051;?#38171;屽湪浣?#37922;?#29825;?#35120;曟椂鍊?#38171;?#29781;?#26851;栧厛?#30078;涔?#29825;?#35120;曠粨鏋?#38171;岀劧鍚庡鏄?#29825;?#35120;?#37721;?#38322;?#37510;?#37721;?#28000;妸PL/SQL璁?#35120;曠湅浣?#37828;?#28051;?#37340;鐢?#37812;疯嚜?#30078;涔?#37928;勬暟鎹?#32491;诲瀷銆?

    set serveroutput on;
                declare
                type person is record
                (
                empno cus_emp_basic.emp_no%type,
                empzc cus_emp_basic.emp_zc%type);
                person1 person;
                cursor mycur(vartype number)is
                select emp_no,emp_zc from cus_emp_basic
                where com_no=vartype;
                begin
                if mycur%isopen = false then
                open mycur(000627);
                end if;
                loop
                fetch mycur into person1;
                exit when mycur%notfound;
                dbms_output.put_line('闆囧憳缂?#37721;?'||person1.empno||',鍦板潃:'||person1.empzc);
                end loop;
                close mycur;
                end;


    鍏稿瀷?#29238;鏍噁or 寰?#37916;?

    ?#29238;鏍噁or寰?#37916;?#32448;?#37828;?#32448;烘父鏍?#37928;?#28051;绉?#36423;?#37817;蜂娇鐢?#37826;?#23534;?#38171;屽畠浣?#37922;for寰?#37916;?#28186;?#23046;?#29831;?#37721;栫粨鏋滈泦涓?#37928;勮?#23678;暟鎹?#38171;屽綋form寰?#37916;?#23534;濮嬫椂锛屾父鏍囪嚜?#23017;鎵撳紑锛堜笉闇瑕乷pen锛?#38171;?#23011;?#23536;?#37916;?#28051;娆?#32495;荤粺鑷姩璇?#37721;栨父鏍囧?#25779;墠琛?#37928;勬暟鎹?#38171;堜笉闇瑕乫etch)锛屽綋閫鍑篺or寰?#37916;椂锛屾父鏍?#29722;?#38007;姩鍏?#38338;?#38171;堜笉闇瑕?#28003;?#37922;close锛?#37510;?#28003;?#37922;父鏍噁or寰?#37916;?#37928;勬椂鍊欎笉?#20824;浣?#37922;open璇?#37721;?#38171;宖etch璇?#37721;拰close璇?#37721;?#38171;屽惁鍒欎細?#39559;鐢熼敊璇?#37510;?

    set serveroutput on;
                declare
                cursor mycur(vartype number)is
                select emp_no,emp_zc from cus_emp_basic
                where com_no=vartype;
                begin
                for person in mycur(000627) loop
                dbms_output.put_line('闆囧憳缂?#37721;?'||person.emp_no||',鍦板潃:'||person.emp_zc);
                end loop;
                end;



    ]]> ͼͼֽӡˢ
    <optgroup id="iaykq"><small id="iaykq"></small></optgroup>
    <menu id="iaykq"></menu>
    <bdo id="iaykq"><nav id="iaykq"></nav></bdo>
  • <optgroup id="iaykq"><small id="iaykq"></small></optgroup>
    <menu id="iaykq"></menu>
    <bdo id="iaykq"><nav id="iaykq"></nav></bdo>