涓�. Java鍩虹閮ㄥ垎......................................................................................................21銆佷竴涓�".java"婧愭枃浠朵腑鏄惁鍙互鍖呮嫭澶氫釜绫伙紙涓嶆槸鍐呴儴绫伙級锛熸湁浠�涔堥檺鍒讹紵.....22銆丣ava鏈夋病鏈塯oto?..........................................................................................23銆佽璇�&鍜�&&鐨勫尯鍒��......................................................................................24銆佸湪JAVA涓浣曡烦鍑哄綋鍓嶇殑澶氶噸宓屽寰幆锛�...................................................25銆乻witch璇彞鑳藉惁浣滅敤鍦╞yte涓婏紝鑳藉惁浣滅敤鍦╨ong涓婏紝鑳藉惁浣滅敤鍦⊿tring涓�?...26銆乻hort s1 =1; s1 = s1 + 1;鏈変粈涔堥敊? short s1 = 1; s1 += 1;鏈変粈涔堥敊?..................27銆乧har鍨嬪彉閲忎腑鑳戒笉鑳藉瓨璐竴涓腑鏂囨眽瀛�?涓轰粈涔�?............................................28銆佺敤鏈�鏈夋晥鐜囩殑鏂规硶绠楀嚭2涔樹互8绛夋柤鍑�?29銆佽璁捐涓�涓竴鐧句嚎鐨勮绠楀櫒..........................................................................210銆佷娇鐢╢inal鍏抽敭瀛椾慨楗颁竴涓彉閲忔椂锛屾槸寮曠敤涓嶈兘鍙橈紝杩樻槸寮曠敤鐨勫璞′笉鑳藉彉锛�211銆�"=="鍜宔quals鏂规硶绌剁珶鏈変粈涔堝尯鍒紵...........................................................212銆侀潤鎬佸彉閲忓拰瀹炰緥鍙橀噺鐨勫尯鍒紵.....................................................................213銆佹槸鍚﹀彲浠ヤ粠涓�涓猻tatic鏂规硶鍐呴儴鍙戝嚭瀵归潪static鏂规硶鐨勮皟鐢紵........................214銆両nteger涓巌nt鐨勫尯鍒�.....................................................................................215銆丮ath.round(11.5)绛夋柤澶氬皯?Math.round(-11.5)绛夋柤澶氬皯?...............................216銆佷笅闈㈢殑浠g爜鏈変粈涔堜笉濡ヤ箣澶�?.......................................................................217銆佽璇村嚭浣滅敤鍩焢ublic锛宲rivate锛宲rotected锛屼互鍙婁笉鍐欐椂鐨勫尯鍒�.......................218銆丱verload鍜孫verride鐨勫尯鍒�侽verloaded鐨勬柟娉曟槸鍚﹀彲浠ユ敼鍙樿繑鍥炲�肩殑绫诲瀷?219銆佹瀯閫犲櫒Constructor鏄惁鍙override?..........................................................220銆佹帴鍙f槸鍚﹀彲缁ф壙鎺ュ彛?鎶借薄绫绘槸鍚﹀彲瀹炵幇(implements)鎺ュ彛?鎶借薄绫绘槸鍚﹀彲缁ф壙鍏蜂綋绫�(concreteclass)?鎶借薄绫讳腑鏄惁鍙互鏈夐潤鎬佺殑main鏂规硶锛�.......................................................................221銆佸啓clone()鏂规硶鏃讹紝閫氬父閮芥湁涓�琛屼唬鐮侊紝鏄粈涔堬紵.........................................222銆侀潰鍚戝璞$殑鐗瑰緛鏈夊摢浜涙柟闈�.........................................................................223銆乯ava涓疄鐜板鎬佺殑鏈哄埗鏄粈涔堬紵..................................................................224銆乤bstractclass鍜宨nterface鏈変粈涔堝尯鍒�?...........................................................225銆乤bstract鐨刴ethod鏄惁鍙悓鏃舵槸static,鏄惁鍙悓鏃舵槸native锛屾槸鍚﹀彲鍚屾椂鏄痵ynchronized?226銆佷粈涔堟槸鍐呴儴绫伙紵StaticNested Class 鍜� Inner Class鐨勪笉鍚屻��..........................227銆佸唴閮ㄧ被鍙互寮曠敤瀹冪殑鍖呭惈绫荤殑鎴愬憳鍚楋紵鏈夋病鏈変粈涔堥檺鍒讹紵...........................228銆丄nonymousInner Class (鍖垮悕鍐呴儴绫�)鏄惁鍙互extends(缁ф壙)鍏跺畠绫伙紝鏄惁鍙互implements(瀹炵幇)interface(鎺ュ彛)?...................................................................................................................229銆乻uper.getClass()鏂规硶璋冪敤.....................................................................230銆丼tring鏄渶鍩烘湰鐨勬暟鎹被鍨嬪悧?.....................................................................231銆丼tring s = "Hello";s = s + " world!";杩欎袱琛屼唬鐮佹墽琛屽悗锛屽師濮嬬殑String瀵硅薄涓殑鍐呭鍒板簳鍙樹簡娌℃湁锛熉� 聽 232銆佹槸鍚﹀彲浠ョ户鎵縎tring绫�?..............................................................................233銆丼tring s =new String("xyz");鍒涘缓浜嗗嚑涓猄tring Object?浜岃�呬箣闂存湁浠�涔堝尯鍒紵 234銆丼tring鍜孲tringBuffer鐨勫尯鍒�.......................................................................235銆佸浣曟妸涓�娈甸�楀彿鍒嗗壊鐨勫瓧绗︿覆杞崲鎴愪竴涓暟缁�?...........................................236銆佹暟缁勬湁娌℃湁length()杩欎釜鏂规硶?String鏈夋病鏈塴ength()杩欎釜鏂规硶锛�...................237銆佷笅闈㈣繖鏉¤鍙ヤ竴鍏卞垱寤轰簡澶氬皯涓璞★細Strings="a"+"b"+"c"+"d";.................238銆乼ry {}閲屾湁涓�涓猺eturn璇彞锛岄偅涔堢揣璺熷湪杩欎釜try鍚庣殑finally{}閲岀殑code浼氫笉浼氳鎵ц锛屼粈涔堟椂鍊欒鎵ц锛屽湪return鍓嶈繕鏄悗?.................................................................................................239銆佷笅闈㈢殑绋嬪簭浠g爜杈撳嚭鐨勭粨鏋滄槸澶氬皯锛�...........................................................240銆乫inal,finally, finalize鐨勫尯鍒��......................................................................241銆佽繍琛屾椂寮傚父涓庝竴鑸紓甯告湁浣曞紓鍚岋紵..............................................................242銆乪rror鍜宔xception鏈変粈涔堝尯鍒�?.....................................................................243銆丣ava涓殑寮傚父澶勭悊鏈哄埗鐨勭畝鍗曞師鐞嗗拰搴旂敤銆�................................................244銆佽鍐欏嚭浣犳渶甯歌鍒扮殑5涓猺untimeexception銆�...............................................245銆丣AVA璇█濡備綍杩涜寮傚父澶勭悊锛屽叧閿瓧锛歵hrows,throw,try,catch,finally鍒嗗埆浠h〃浠�涔堟剰涔夛紵鍦╰ry鍧椾腑鍙互鎶涘嚭寮傚父鍚楋紵............................................................................................................246銆乯ava涓湁鍑犵鏂规硶鍙互瀹炵幇涓�涓嚎绋嬶紵鐢ㄤ粈涔堝叧閿瓧淇グ鍚屾鏂规硶? stop()鍜宻uspend()鏂规硶涓轰綍涓嶆帹鑽愪娇鐢紵..........................................................................................................................247銆乻leep()鍜� wait() 鏈変粈涔堝尯鍒�?.....................................................................248銆佸悓姝ュ拰寮傛鏈変綍寮傚悓锛屽湪浠�涔堟儏鍐典笅鍒嗗埆浣跨敤浠栦滑锛熶妇渚嬭鏄庛��.................249.涓嬮潰涓や釜鏂规硶鍚屾鍚楋紵锛堣嚜宸卞彂鏄庯級...........................................................250銆佸绾跨▼鏈夊嚑绉嶅疄鐜版柟娉�?鍚屾鏈夊嚑绉嶅疄鐜版柟娉�?.............................................251銆佸惎鍔ㄤ竴涓嚎绋嬫槸鐢╮un()杩樻槸start()?............................................................252銆佸綋涓�涓嚎绋嬭繘鍏ヤ竴涓璞$殑涓�涓猻ynchronized鏂规硶鍚庯紝鍏跺畠绾跨▼鏄惁鍙繘鍏ユ瀵硅薄鐨勫叾瀹冩柟娉�?聽 253銆佺嚎绋嬬殑鍩烘湰姒傚康銆佺嚎绋嬬殑鍩烘湰鐘舵�佷互鍙婄姸鎬佷箣闂寸殑鍏崇郴...............................254銆佺畝杩皊ynchronized鍜宩ava.util.concurrent.locks.Lock鐨勫紓鍚岋紵.......................255銆佽璁�4涓嚎绋嬶紝鍏朵腑涓や釜绾跨▼姣忔瀵筳澧炲姞1锛屽彟澶栦袱涓嚎绋嬪j姣忔鍑忓皯1銆傚啓鍑虹▼搴忋�偮� 256銆佸瓙绾跨▼寰幆10娆★紝鎺ョ潃涓荤嚎绋嬪惊鐜�100锛屾帴鐫�鍙堝洖鍒板瓙绾跨▼寰幆10娆★紝鎺ョ潃鍐嶅洖鍒颁富绾跨▼鍙堝惊鐜�100锛屽姝ゅ惊鐜�50娆★紝璇峰啓鍑虹▼搴忋��..................................................................................257銆佷粙缁岰ollection妗嗘灦鐨勭粨鏋�..........................................................................258銆丆ollection妗嗘灦涓疄鐜版瘮杈冭瀹炵幇浠�涔堟帴鍙�..................................................259銆丄rrayList鍜孷ector鐨勫尯鍒�............................................................................260銆丠ashMap鍜孒ashtable鐨勫尯鍒�.......................................................................261銆丩ist鍜� Map 鍖哄埆?......................................................................................262銆丩ist, Set,Map鏄惁缁ф壙鑷狢ollection鎺ュ彛?....................................................263銆丩ist銆丮ap銆丼et涓変釜鎺ュ彛锛屽瓨鍙栧厓绱犳椂锛屽悇鏈変粈涔堢壒鐐癸紵............................264銆佽鍑篈rrayList,Vector,LinkedList鐨勫瓨鍌ㄦ�ц兘鍜岀壒鎬�......................................265銆佸幓鎺変竴涓猇ector闆嗗悎涓噸澶嶇殑鍏冪礌..............................................................266銆丆ollection鍜� Collections鐨勫尯鍒��...............................................................267銆丼et閲岀殑鍏冪礌鏄笉鑳介噸澶嶇殑锛岄偅涔堢敤浠�涔堟柟娉曟潵鍖哄垎閲嶅涓庡惁鍛�?鏄敤==杩樻槸equals()?瀹冧滑鏈変綍鍖哄埆?聽 聽 268銆佷綘鎵�鐭ラ亾鐨勯泦鍚堢被閮芥湁鍝簺锛熶富瑕佹柟娉曪紵....................................................269銆佷袱涓璞″�肩浉鍚�(x.equals(y)== true)锛屼絾鍗村彲鏈変笉鍚岀殑hash code锛岃繖鍙ヨ瘽瀵逛笉瀵�?聽 270銆乀reeSet閲岄潰鏀惧璞★紝濡傛灉鍚屾椂鏀惧叆浜嗙埗绫诲拰瀛愮被鐨勫疄渚嬪璞★紝閭f瘮杈冩椂浣跨敤鐨勬槸鐖剁被鐨刢ompareTo鏂规硶锛岃繕鏄娇鐢ㄧ殑瀛愮被鐨刢ompareTo鏂规硶锛岃繕鏄姏寮傚父锛�.................................................271銆佽鍑轰竴浜涘父鐢ㄧ殑绫伙紝鍖咃紝鎺ュ彛锛岃鍚勪妇5涓�................................................272銆乯ava涓湁鍑犵绫诲瀷鐨勬祦锛烰DK涓烘瘡绉嶇被鍨嬬殑娴佹彁渚涗簡涓�浜涙娊璞$被浠ヤ緵缁ф壙锛岃璇村嚭浠栦滑鍒嗗埆鏄摢浜涚被锛熉� 273銆佸瓧鑺傛祦涓庡瓧绗︽祦鐨勫尯鍒�................................................................................274銆佷粈涔堟槸java搴忓垪鍖栵紝濡備綍瀹炵幇java搴忓垪鍖栵紵鎴栬�呰瑙i噴Serializable鎺ュ彛鐨勪綔鐢ㄣ�偮� 275銆佹弿杩颁竴涓婮VM鍔犺浇class鏂囦欢鐨勫師鐞嗘満鍒�?...................................................276銆乭eap鍜宻tack鏈変粈涔堝尯鍒��..........................................................................277銆丟C鏄粈涔�?涓轰粈涔堣鏈塆C?.......................................................................278銆佸瀮鍦惧洖鏀剁殑浼樼偣鍜屽師鐞嗐�傚苟鑰冭檻2绉嶅洖鏀舵満鍒躲��.........................................279銆佸瀮鍦惧洖鏀跺櫒鐨勫熀鏈師鐞嗘槸浠�涔堬紵鍨冨溇鍥炴敹鍣ㄥ彲浠ラ┈涓婂洖鏀跺唴瀛樺悧锛熸湁浠�涔堝姙娉曚富鍔ㄩ�氱煡铏氭嫙鏈鸿繘琛屽瀮鍦惧洖鏀讹紵..........................................................................................................................280銆佷粈涔堟椂鍊欑敤assert銆�.....................................................................................281銆乯ava涓細瀛樺湪鍐呭瓨娉勬紡鍚楋紝璇风畝鍗曟弿杩般��....................................................282銆佽兘涓嶈兘鑷繁鍐欎釜绫伙紝涔熷彨java.lang.String锛�.................................................283.Java浠g爜鏌ラ敊......................................................................................................2浜�.绠楁硶涓庣紪绋�.........................................................................................................21銆佺紪鍐欎竴涓▼搴忥紝灏哸.txt鏂囦欢涓殑鍗曡瘝涓巄.txt鏂囦欢涓殑鍗曡瘝浜ゆ浛鍚堝苟鍒癱.txt鏂囦欢涓紝a.txt鏂囦欢涓殑鍗曡瘝鐢ㄥ洖杞︾鍒嗛殧锛宐.txt鏂囦欢涓敤鍥炶溅鎴栫┖鏍艰繘琛屽垎闅斻��...................................................22銆佺紪鍐欎竴涓▼搴忥紝灏哾:\java鐩綍涓嬬殑鎵�鏈�.java鏂囦欢澶嶅埗鍒癲:\jad鐩綍涓嬶紝骞跺皢鍘熸潵鏂囦欢鐨勬墿灞曞悕浠�.java鏀逛负.jad銆�..........................................................................................................................23銆佺紪鍐欎竴涓埅鍙栧瓧绗︿覆鐨勫嚱鏁帮紝杈撳叆涓轰竴涓瓧绗︿覆鍜屽瓧鑺傛暟锛岃緭鍑轰负鎸夊瓧鑺傛埅鍙栫殑瀛楃涓诧紝浣嗚淇濊瘉姹夊瓧涓嶈鎴彇鍗婁釜锛屽鈥滄垜ABC鈥濓紝4锛屽簲璇ユ埅鍙栤�滄垜AB鈥濓紝杈撳叆鈥滄垜ABC姹塂EF鈥濓紝6锛屽簲璇ヨ緭鍑衡�滄垜ABC鈥濓紝鑰屼笉鏄�滄垜ABC+姹夌殑鍗婁釜鈥濄��....................................................................................24銆佹湁涓�涓瓧绗︿覆锛屽叾涓寘鍚腑鏂囧瓧绗︺�佽嫳鏂囧瓧绗﹀拰鏁板瓧瀛楃锛岃缁熻鍜屾墦鍗板嚭鍚勪釜瀛楃鐨勪釜鏁般�偮� 聽 25銆佽鏄庣敓娲讳腑閬囧埌鐨勪簩鍙夋爲锛岀敤java瀹炵幇浜屽弶鏍�..............................................26銆佷粠绫讳技濡備笅鐨勬枃鏈枃浠朵腑璇诲彇鍑烘墍鏈夌殑濮撳悕锛屽苟鎵撳嵃鍑洪噸澶嶇殑濮撳悕鍜岄噸澶嶇殑娆℃暟锛屽苟鎸夐噸澶嶆鏁版帓搴忥細聽 聽 27銆佸啓涓�涓猄ingleton鍑烘潵銆�................................................................................28銆侀�掑綊绠楁硶棰�1................................................................................................29銆侀�掑綊绠楁硶棰�2................................................................................................210銆佹帓搴忛兘鏈夊摢鍑犵鏂规硶锛熻鍒椾妇銆傜敤JAVA瀹炵幇涓�涓揩閫熸帓搴忋��.....................211銆佹湁鏁扮粍a[n]锛岀敤java浠g爜灏嗘暟缁勫厓绱犻『搴忛鍊�.............................................212锛庨噾棰濊浆鎹紝闃挎媺浼暟瀛楃殑閲戦杞崲鎴愪腑鍥戒紶缁熺殑褰㈠紡濡傦細锛堬骏1011锛夛紞>锛堜竴鍗冮浂涓�鎷句竴鍏冩暣锛夎緭鍑恒�偮� 聽 2涓�.html&JavaScript&ajax閮ㄥ垎...................................................................................21.鍒ゆ柇绗簩涓棩鏈熸瘮绗竴涓棩鏈熷ぇ....................................................................22.鐢╰able鏄剧ずn鏉¤褰曪紝姣�3琛屾崲涓�娆¢鑹诧紝鍗�1锛�2锛�3鐢ㄧ孩鑹插瓧浣擄紝4锛�5锛�6鐢ㄧ豢鑹插瓧浣擄紝7锛�8锛�9鐢ㄧ孩棰滆壊瀛椾綋銆�...................................................................................................................23銆丠TML鐨� form 鎻愪氦涔嬪墠濡備綍楠岃瘉鏁板�兼枃鏈鐨勫唴瀹瑰叏閮ㄤ负鏁板瓧?鍚﹀垯鐨勮瘽鎻愮ず鐢ㄦ埛骞剁粓姝㈡彁浜�?聽 聽 聽 24銆佽鍐欏嚭鐢ㄤ簬鏍¢獙HTML鏂囨湰妗嗕腑杈撳叆鐨勫唴瀹瑰叏閮ㄤ负鏁板瓧鐨刯avascript浠g爜......25銆佽璇翠綘鐢ㄨ繃閭d簺ajax鎶�鏈拰妗嗘灦锛岃璇村畠浠殑鍖哄埆.......................................2鍥�. Java web閮ㄥ垎......................................................................................................21銆乀omcat鐨勪紭鍖栫粡楠�........................................................................................22銆丠TTP璇锋眰鐨凣ET涓嶱OST鏂瑰紡鐨勫尯鍒�.........................................................23銆佽В閲婁竴涓嬩粈涔堟槸servlet;.................................................................................24銆佽涓�璇碨ervlet鐨勭敓鍛藉懆鏈�?...........................................................................25銆丼ervlet鐨勫熀鏈灦鏋�........................................................................................26銆丼ERVLET API涓璮orward()涓巖edirect()鐨勫尯鍒紵...........................................27銆佷粈涔堟儏鍐典笅璋冪敤doGet()鍜宒oPost()锛�............................................................28銆丷equest瀵硅薄鐨勪富瑕佹柟娉曪細.............................................................................29銆乫orward鍜宺edirect鐨勫尯鍒�.............................................................................210銆乺equest.getAttribute()鍜� request.getParameter() 鏈変綍鍖哄埆?............................211.jsp鏈夊摢浜涘唴缃璞�?浣滅敤鍒嗗埆鏄粈涔�?鍒嗗埆鏈変粈涔堟柟娉曪紵..............................212.jsp鏈夊摢浜涘姩浣�?浣滅敤鍒嗗埆鏄粈涔�?..................................................................213銆丣SP鐨勫父鐢ㄦ寚浠�...........................................................................................214.JSP涓姩鎬両NCLUDE涓庨潤鎬両NCLUDE鐨勫尯鍒紵.........................................215銆佷袱绉嶈烦杞柟寮忓垎鍒槸浠�涔�?鏈変粈涔堝尯鍒�?........................................................216銆侀〉闈㈤棿瀵硅薄浼犻�掔殑鏂规硶................................................................................217銆丣SP鍜孲ervlet鏈夊摢浜涚浉鍚岀偣鍜屼笉鍚岀偣锛屼粬浠箣闂寸殑鑱旂郴鏄粈涔堬紵................218銆丮VC鐨勫悇涓儴鍒嗛兘鏈夐偅浜涙妧鏈潵瀹炵幇?濡備綍瀹炵幇?........................................219銆佹垜浠湪web搴旂敤寮�鍙戣繃绋嬩腑缁忓父閬囧埌杈撳嚭鏌愮缂栫爜鐨勫瓧绗︼紝濡俰so8859-1绛夛紝濡備綍杈撳嚭涓�涓煇绉嶇紪鐮佺殑瀛楃涓诧紵..........................................................................................................................220锛庣幇鍦ㄨ緭鍏涓暟瀛楋紝浠ラ�楀彿锛屽垎寮�锛涚劧鍚庡彲閫夋嫨鍗囨垨鑰呴檷搴忔帓搴忥紱鎸夋彁浜ら敭灏卞湪鍙︿竴椤甸潰鏄剧ず鎸変粈涔堟帓搴忥紝缁撴灉涓猴紝鎻愪緵reset.............................................................................................2浜�.鏁版嵁搴撻儴鍒�.........................................................................................................21銆佺敤涓ょ鏂瑰紡鏍规嵁閮ㄩ棬鍙蜂粠楂樺埌浣庯紝宸ヨ祫浠庝綆鍒伴珮鍒楀嚭姣忎釜鍛樺伐鐨勪俊鎭��........22銆佸垪鍑哄悇涓儴闂ㄤ腑宸ヨ祫楂樹簬鏈儴闂ㄧ殑骞冲潎宸ヨ祫鐨勫憳宸ユ暟鍜岄儴闂ㄥ彿锛屽苟鎸夐儴闂ㄥ彿鎺掑簭聽 聽 23銆佸瓨鍌ㄨ繃绋嬩笌瑙﹀彂鍣ㄥ繀椤昏锛岀粡甯歌闈㈣瘯鍒�?....................................................24銆佹暟鎹簱涓夎寖寮忔槸浠�涔�?...................................................................................25銆佽鍑轰竴浜涙暟鎹簱浼樺寲鏂归潰鐨勭粡楠�?..................................................................26銆乽nion鍜寀nion all鏈変粈涔堜笉鍚�?.......................................................................27.鍒嗛〉璇彞.........................................................................................................28.鐢ㄤ竴鏉QL璇彞鏌ヨ鍑烘瘡闂ㄨ閮藉ぇ浜�80鍒嗙殑瀛︾敓濮撳悕..................................29.鎵�鏈夐儴闂ㄤ箣闂寸殑姣旇禌缁勫悎................................................................................210.姣忎釜鏈堜唤鐨勫彂鐢熼閮芥瘮101绉戠洰澶氱殑绉戠洰......................................................211.缁熻姣忓勾姣忔湀鐨勪俊鎭�......................................................................................212.鏄剧ず鏂囩珷鏍囬锛屽彂甯栦汉銆佹渶鍚庡洖澶嶆椂闂�..........................................................213.鍒犻櫎闄や簡id鍙蜂笉鍚�,鍏朵粬閮界浉鍚岀殑瀛︾敓鍐椾綑淇℃伅.............................................214.鑸┖缃戠殑鍑犱釜鑸彮鏌ヨ棰橈細...........................................................................215.鏌ュ嚭姣旂粡鐞嗚柂姘磋繕楂樼殑鍛樺伐淇℃伅锛�.................................................................216銆佹眰鍑哄皬浜�45宀佺殑鍚勪釜鑰佸笀鎵�甯︾殑澶т簬12宀佺殑瀛︾敓浜烘暟...............................217.姹傚嚭鍙戝笘鏈�澶氱殑浜猴細......................................................................................218銆佷竴涓敤鎴疯〃涓湁涓�涓Н鍒嗗瓧娈碉紝鍋囧鏁版嵁搴撲腑鏈�100澶氫竾涓敤鎴凤紝鑻ヨ鍦ㄦ瘡骞寸涓�澶╁噷鏅ㄥ皢绉垎娓呴浂锛屼綘灏嗚�冭檻浠�涔堬紝浣犲皢鎯充粈涔堝姙娉曡В鍐�?.......................................................................219銆佷竴涓敤鎴峰叿鏈夊涓鑹诧紝璇锋煡璇㈠嚭璇ヨ〃涓叿鏈夎鐢ㄦ埛鐨勬墍鏈夎鑹茬殑鍏朵粬鐢ㄦ埛銆偮� 聽 聽 220.xxx鍏徃鐨剆ql闈㈣瘯.......................................................................................221銆佹敞鍐孞dbc椹卞姩绋嬪簭鐨勪笁绉嶆柟寮�....................................................................222銆佺敤JDBC濡備綍璋冪敤瀛樺偍杩囩▼.........................................................................223銆丣DBC涓殑PreparedStatement鐩告瘮Statement鐨勫ソ澶�.....................................224.鍐欎竴涓敤jdbc杩炴帴骞惰闂畂racle鏁版嵁鐨勭▼搴忎唬鐮�..........................................225銆丆lass.forName鐨勪綔鐢�?涓轰粈涔堣鐢�?..............................................................226銆佸ぇ鏁版嵁閲忎笅鐨勫垎椤佃В鍐虫柟娉曘��.....................................................................227銆佺敤 JDBC 鏌ヨ瀛︾敓鎴愮哗鍗�,鎶婁富瑕佷唬鐮佸啓鍑烘潵锛堣�冭瘯姒傜巼鏋佸ぇ锛�................228銆佽繖娈典唬鐮佹湁浠�涔堜笉瓒充箣澶�?...........................................................................229銆佽鍑烘暟鎹繛鎺ユ睜鐨勫伐浣滄満鍒舵槸浠�涔�?.............................................................230銆佷负浠�涔堣鐢∣RM? 鍜� JDBC 鏈変綍涓嶄竴鏍�?.................................................2鍏�. XML閮ㄥ垎............................................................................................................21銆亁ml鏈夊摢浜涜В鏋愭妧鏈�?鍖哄埆鏄粈涔�?.................................................................22銆佷綘鍦ㄩ」鐩腑鐢ㄥ埌浜唜ml鎶�鏈殑鍝簺鏂归潰?濡備綍瀹炵幇鐨�?....................................23銆佺敤jdom瑙f瀽xml鏂囦欢鏃跺浣曡В鍐充腑鏂囬棶棰�?濡備綍瑙f瀽?...................................24銆佺紪绋嬬敤JAVA瑙f瀽XML鐨勬柟寮�......................................................................25銆乆ML鏂囨。瀹氫箟鏈夊嚑绉嶅舰寮忥紵瀹冧滑涔嬮棿鏈変綍鏈川鍖哄埆锛熻В鏋怷ML鏂囨。鏈夊摢鍑犵鏂瑰紡锛熉� 聽 2涓�.娴佽鐨勬鏋朵笌鏂版妧鏈�...........................................................................................21銆佽皥璋堜綘瀵筍truts鐨勭悊瑙c��...............................................................................22銆佽皥璋堜綘瀵笻ibernate鐨勭悊瑙c��.........................................................................23銆丄OP鐨勪綔鐢ㄣ��...............................................................................................24銆佷綘瀵筍pring鐨勭悊瑙c��....................................................................................25銆佽皥璋圫truts涓殑Actionservlet銆�.....................................................................26銆丼truts浼樼己鐐� 浼樼偣锛� 1.瀹炵幇MVC妯″紡锛岀粨鏋勬竻鏅�,浣垮紑鍙戣�呭彧鍏虫敞涓氬姟閫昏緫鐨勫疄鐜�. 27銆丼TRUTS鐨勫簲鐢�(濡係TRUTS鏋舵瀯).................................................................28銆佽璇磗truts1涓巗truts2鐨勫尯鍒��......................................................................29銆乭ibernate涓殑update()鍜宻aveOrUpdate()鐨勫尯鍒紝session鐨刲oad()鍜実et()鐨勫尯鍒�偮� 聽 210銆佺畝杩癏ibernate鍜� JDBC 鐨勪紭缂虹偣?濡備綍涔﹀啓涓�涓� one to many閰嶇疆鏂囦欢..211銆乮Batis涓嶩ibernate鏈変粈涔堜笉鍚�?....................................................................212銆佸啓Hibernate鐨勪竴瀵瑰鍜屽瀵逛竴鍙屽悜鍏宠仈鐨刼rm閰嶇疆?...................................29銆乭ibernate鐨刬nverse灞炴�х殑浣滅敤?.....................................................................213銆佸湪DAO涓浣曚綋鐜癉AO璁捐妯″紡?............................................................214銆乻pring+Hibernate涓鎵樻柟妗堟�庝箞閰嶇疆?........................................................215銆乻pring+Hibernate涓鎵樻柟妗堟�庝箞閰嶇疆?........................................................216.hibernate杩涜澶氳〃鏌ヨ姣忎釜琛ㄤ腑鍚勫彇鍑犱釜瀛楁锛屼篃灏辨槸璇存煡璇㈠嚭鏉ョ殑缁撴灉闆嗘病鏈変竴涓疄浣撶被涓庝箣瀵瑰簲濡備綍瑙e喅锛�..........................................................................................................................217.浠嬬粛涓�涓婬ibernate鐨勪簩绾х紦瀛�......................................................................218銆丼pring鐨勪緷璧栨敞鍏ユ槸浠�涔堟剰鎬�?缁欎竴涓� Bean鐨� message灞炴��,瀛楃涓茬被鍨�,娉ㄥ叆鍊间负 "Hello"鐨� XML閰嶇疆鏂囦欢璇ユ�庝箞鍐�?................................................................................................219銆丣do鏄粈涔�?.................................................................................................220銆佷粈涔堟槸spring鐨処OC AOP.........................................................................221銆丼TRUTS鐨勫伐浣滄祦绋嬶紒................................................................................222銆乻pring涓嶦JB鐨勫尯鍒紒锛�............................................................................2鍏�.杞欢宸ョ▼涓庤璁℃ā寮�...........................................................................................21銆乁ML鏂归潰.....................................................................................................22銆乯2ee甯哥敤鐨勮璁℃ā寮忥紵璇存槑宸ュ巶妯″紡銆�.........................................................23銆佸紑鍙戜腑閮界敤鍒颁簡閭d簺璁捐妯″紡?鐢ㄥ湪浠�涔堝満鍚�?...............................................2涔�. j2ee閮ㄥ垎..............................................................................................................21銆丅S涓嶤S鐨勮仈绯讳笌鍖哄埆銆�..............................................................................22銆佸簲鐢ㄦ湇鍔″櫒涓嶹EBSERVER鐨勫尯鍒紵..........................................................23銆佸簲鐢ㄦ湇鍔″櫒鏈夐偅浜涳紵.....................................................................................24銆丣2EE鏄粈涔堬紵..............................................................................................25銆丣2EE鏄妧鏈繕鏄钩鍙拌繕鏄鏋讹紵浠�涔堟槸J2EE.............................................26銆佽瀵逛互涓嬪湪J2EE涓父鐢ㄧ殑鍚嶈瘝杩涜瑙i噴(鎴栫畝鍗曟弿杩�)...................................27銆佸浣曠粰weblogic鎸囧畾澶у皬鐨勫唴瀛�?..................................................................28銆佸浣曡瀹氱殑weblogic鐨勭儹鍚姩妯″紡(寮�鍙戞ā寮�)涓庝骇鍝佸彂甯冩ā寮�?.....................29銆佸浣曞惎鍔ㄦ椂涓嶉渶杈撳叆鐢ㄦ埛鍚嶄笌瀵嗙爜?..............................................................210銆佸湪weblogic绠$悊鍒跺彴涓涓�涓簲鐢ㄥ煙(鎴栬�呰鏄竴涓綉绔�,Domain)杩涜jms鍙奺jb鎴栬繛鎺ユ睜绛夌浉鍏充俊鎭繘琛岄厤缃悗,瀹為檯淇濆瓨鍦ㄤ粈涔堟枃浠朵腑?.................................................................................211銆佽璇磜eblogic涓竴涓狣omain鐨勭己鐪佺洰褰曠粨鏋�?姣斿瑕佸皢涓�涓畝鍗曠殑helloWorld.jsp鏀惧叆浣曠洰褰曚笅,鐒剁殑鍦ㄦ祻瑙堝櫒涓婂氨鍙墦鍏ttp://涓绘満:绔彛鍙�//helloword.jsp灏卞彲浠ョ湅鍒拌繍琛岀粨鏋滀簡?鍙堟瘮濡傝繖鍏朵腑鐢ㄥ埌浜嗕竴涓嚜宸卞啓鐨刯avaBean璇ュ浣曞姙?..........................................................................................................212銆佸湪weblogic涓彂甯僥jb闇�娑夊強鍒板摢浜涢厤缃枃浠�..............................................213銆佸浣曞湪weblogic涓繘琛宻sl閰嶇疆涓庡鎴风鐨勮璇侀厤缃垨璇磋j2ee(鏍囧噯)杩涜ssl鐨勯厤缃�?聽 214銆佸浣曟煡鐪嬪湪weblogic涓凡缁忓彂甯冪殑EJB?......................................................2鍗�. EBJ閮ㄥ垎.............................................................................................................21銆丒JB鏄熀浜庡摢浜涙妧鏈疄鐜扮殑锛熷苟璇村嚭SessionBean鍜孍ntityBean鐨勫尯鍒紝StatefulBean鍜孲tatelessBean鐨勫尯鍒��..........................................................................................................................22銆佺畝瑕佽涓�涓� EJB 鐨� 7 涓猅ransaction Level?.................................................23銆丒JB涓嶫AVA BEAN鐨勫尯鍒紵........................................................................24銆丒JB鍖呮嫭锛圫essionBean,EntityBean锛夎鍑轰粬浠殑鐢熷懡鍛ㄦ湡锛屽強濡備綍绠$悊浜嬪姟鐨勶紵聽 聽 25銆丒JB瀹瑰櫒鎻愪緵鐨勬湇鍔�.....................................................................................26銆丒JB鐨勬縺娲绘満鍒�............................................................................................27銆丒JB鐨勫嚑绉嶇被鍨�............................................................................................28銆佸鏈嶇璋冪敤EJB瀵硅薄鐨勫嚑涓熀鏈楠�............................................................2鍗佷竴. webservice閮ㄥ垎................................................................................................21銆乄EBSERVICE鍚嶈瘝瑙i噴銆侸SWDL寮�鍙戝寘鐨勪粙缁嶃�侸AXP銆丣AXM鐨勮В閲娿�係OAP銆乁DDI,WSDL瑙i噴銆偮� 聽 22銆丆ORBA鏄粈涔�?鐢ㄩ�旀槸浠�涔�?.........................................................................23.Linux.....................................................................................................................24銆丩INUX涓嬬嚎绋嬶紝GDI绫荤殑瑙i噴銆�..................................................................25.闂緱绋�閲岀硦娑傜殑棰�................................................................................................26銆佸洓绉嶄細璇濊窡韪妧鏈�........................................................................................27銆佺畝杩伴�昏緫鎿嶄綔(&,|,^)涓庢潯浠舵搷浣�(&&,||)鐨勫尯鍒��............................................2鍗佷簩.鍏朵粬................................................................................................................21銆佽鐢ㄨ嫳鏂囩畝鍗曚粙缁嶄竴涓嬭嚜宸�..........................................................................22銆佽鎶奾ttp://tomcat.apache.org/ 棣栭〉鐨勮繖涓�娈佃瘽鐢ㄤ腑鏂囩炕璇戜竴涓�?.....................23銆佺編璧勮蒋浠跺叕鍙窲AVA宸ョ▼甯堢數璇濋潰璇曢鐩�......................................................2 杩欏闈㈣瘯棰樹富瑕佺洰鐨勬槸甯姪閭d簺杩樻病鏈塲ava杞欢寮�鍙戝疄闄呭伐浣滅粡楠岋紝鑰屾鍦ㄥ姫鍔涘鎵緅ava杞欢寮�鍙戝伐浣滅殑鏈嬪弸鍦ㄧ瑪璇曟椂鏇村ソ鍦拌耽寰楃瑪璇曞拰闈㈣瘯銆傜敱浜庤繖濂楅潰璇曢娑夊強鐨勮寖鍥村緢娉涳紝寰堝箍锛屽緢鏉傦紝澶у涓嶅彲鑳戒竴澶╀袱澶╁氨鐪嬪畬鍜屽瀹岃繖濂楅潰璇曞疂鍏革紝鍗充娇浣犲凡缁忓杩囦簡鏈夊叧鐨勬妧鏈紝閭d箞鑷冲皯涔熼渶瑕佷竴涓湀鐨勬椂闂存墠鑳芥秷鍖栧拰鎺屾彙杩欏闈㈣瘯瀹濆吀锛屾墍浠ワ紝澶у搴旇鏃╀綔鍑嗗锛屼粠鎷垮埌杩欏闈㈣瘯瀹濆吀涔嬫棩璧凤紝灏辫鍧氭寔鍦ㄦ瘡澶╅棽鏆囦箣浣欏涔犲叾涓嚑閬撻鐩紝鏃ョН鏈堢疮锛岀瓑鍒板嚭鍘婚潰璇曟椂锛屼竴鍒囬兘姘村埌娓犳垚锛岄潰璇曟椂灏辫嚜鐒朵細娓稿垉鏈変綑浜嗐�傜瓟棰樻椂锛屽厛绛旀槸浠�涔堬紝鍐嶇瓟鏈変粈涔堜綔鐢ㄥ拰瑕佹敞鎰忎粈涔堬紙杩欓儴鍒嗘渶閲嶈锛屽睍鐜拌嚜宸辩殑蹇冨緱锛夌瓟妗堢殑娈佃惤鍒嗗埆锛屽眰娆″垎鏄庯紝鏉$悊娓呮櫚閮介潪甯搁噸瑕侊紝浠庤繖浜涜〃闈㈢殑涓滆タ涔熷彲浠ョ湅鍑轰竴涓汉鐨勪範鎯�佸姙浜嬮鏍笺�佹潯鐞嗙瓑銆傝璁蹭綘鍋氬嚭绛旀鐨勬�濊矾杩囩▼锛屾垨鑰呰浣犺浣忕瓟妗堢殑鎬濇兂閮藉啓涓嬫潵銆傛妸绛旈鎯崇潃鏄京璁鸿禌銆傜瓟棰樺氨鏄粰鍒汉璁查亾鐞嗐�佹憜浜嬪疄銆傜瓟棰樹笉灞�闄愪簬浠�涔堟牸寮忓拰褰㈠紡锛屽氨鏄灏嗚嚜宸辩殑瀛﹁瘑灞曠幇鍑烘潵锛佸埆鍥犱负浜哄棰樼洰鏈潵灏辨ā妫变袱鍙紝浣犲氨蹇冮噷鑳嗘�拰娌″簳姘斾簡锛屼笉鏁㈠洖绛斾簡銆備綘瑕佸ぇ鑳嗗湴鎸囧嚭瀵规柟棰樼洰寰堟ā绯婂拰浣犵殑瑙傜偣锛屼笉瑕佹妸闈㈣瘯瀹樻兂寰楁湁澶氶珮锛屽叾瀹炰粬鍜屼綘灏辨槸宸笉澶氱殑锛屼綘鎯虫兂锛屽鏋滀粬鎶婁綘鎷涜繘鍘讳簡锛屼綘浠互鍚庡氨鏄悓浜嬩簡锛屽彲涓嶆槸宸笉澶氱殑鍚楋紵鍏充簬灏变笟钖按锛屽鏋滀綘鏄簲灞婄敓锛岄偅涓嶈兘瑕侀珮宸ヨ祫锛屽ソ姣斿ぇ楗肩殑鏁呬簨锛屾病鏈夋枃鍑繕鎯虫嬁楂樺伐璧勶紝灏卞幓涓叧鏉戠己浠�涔堣ˉ浠�涔堝惂锛佸皯鏁颁汉鍩虹纭疄寰堝ソ锛屽湪鏍℃湡闂寸‘瀹炲張鍋氳繃涓�浜涢」鐩紝閭d粛鐒舵槸鍙互瑕佸埌鐩稿楂樼殑宸ヨ祫鐨勩��1. Java鍩虹閮ㄥ垎鍩虹閮ㄥ垎鐨勯『搴忥細鍩烘湰璇硶锛岀被鐩稿叧鐨勮娉曪紝鍐呴儴绫荤殑璇硶锛岀户鎵跨浉鍏崇殑璇硶锛屽紓甯哥殑璇硶锛岀嚎绋嬬殑璇硶锛岄泦鍚堢殑璇硶锛宨o鐨勮娉曪紝铏氭嫙鏈烘柟闈㈢殑璇硶銆�1銆佷竴涓�".java"婧愭枃浠朵腑鏄惁鍙互鍖呮嫭澶氫釜绫伙紙涓嶆槸鍐呴儴绫伙級锛熸湁浠�涔堥檺鍒讹紵鍙互鏈夊涓被锛屼絾鍙兘鏈変竴涓猵ublic鐨勭被锛屽苟涓攑ublic鐨勭被鍚嶅繀椤讳笌鏂囦欢鍚嶇浉涓�鑷淬��2銆丣ava鏈夋病鏈塯oto?java涓殑淇濈暀瀛楋紝鐜板湪娌℃湁鍦╦ava涓娇鐢ㄣ��3銆佽璇�&鍜�&&鐨勫尯鍒��&鍜�&&閮藉彲浠ョ敤浣滈�昏緫涓庣殑杩愮畻绗︼紝琛ㄧず閫昏緫涓庯紙and锛夛紝褰撹繍绠楃涓よ竟鐨勮〃杈惧紡鐨勭粨鏋滈兘涓簍rue鏃讹紝鏁翠釜杩愮畻缁撴灉鎵嶄负true锛屽惁鍒欙紝鍙鏈変竴鏂逛负false锛屽垯缁撴灉涓篺alse銆�&&杩樺叿鏈夌煭璺殑鍔熻兘锛屽嵆濡傛灉绗竴涓〃杈惧紡涓篺alse锛屽垯涓嶅啀璁$畻绗簩涓〃杈惧紡锛屼緥濡傦紝瀵逛簬if(str != null&& !str.equals(鈥溾��))琛ㄨ揪寮忥紝褰搒tr涓簄ull鏃讹紝鍚庨潰鐨勮〃杈惧紡涓嶄細鎵ц锛屾墍浠ヤ笉浼氬嚭鐜癗ullPointerException濡傛灉灏�&&鏀逛负&锛屽垯浼氭姏鍑篘ullPointerException寮傚父銆侷f(x==33 &++y>0) y浼氬闀匡紝If(x==33 && ++y>0)涓嶄細澧為暱&杩樺彲浠ョ敤浣滀綅杩愮畻绗︼紝褰�&鎿嶄綔绗︿袱杈圭殑琛ㄨ揪寮忎笉鏄痓oolean绫诲瀷鏃讹紝&琛ㄧず鎸変綅涓庢搷浣滐紝鎴戜滑閫氬父浣跨敤0x0f鏉ヤ笌涓�涓暣鏁拌繘琛�&杩愮畻锛屾潵鑾峰彇璇ユ暣鏁扮殑鏈�浣�4涓猙it浣嶏紝渚嬪锛�0x31 & 0x0f鐨勭粨鏋滀负0x01銆傚娉細杩欓亾棰樺厛璇翠袱鑰呯殑鍏卞悓鐐癸紝鍐嶈鍑�&&鍜�&鐨勭壒娈婁箣澶勶紝骞跺垪涓句竴浜涚粡鍏哥殑渚嬪瓙鏉ヨ〃鏄庤嚜宸辩悊瑙i�忓交娣卞叆銆佸疄闄呯粡楠屼赴瀵屻�� f4銆佸湪JAVA涓浣曡烦鍑哄綋鍓嶇殑澶氶噸宓屽寰幆锛熷湪Java涓紝瑕佹兂璺冲嚭澶氶噸寰幆锛屽彲浠ュ湪澶栭潰鐨勫惊鐜鍙ュ墠瀹氫箟涓�涓爣鍙凤紝鐒跺悗鍦ㄩ噷灞傚惊鐜綋鐨勪唬鐮佷腑浣跨敤甯︽湁鏍囧彿鐨刡reak璇彞锛屽嵆鍙烦鍑哄灞傚惊鐜�備緥濡傦紝ok:for(int i=0;i<10;i++)聽 聽 {聽 聽 聽 聽 for(int j=0;j<10;j++)聽 聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 System.out.println(鈥渋=鈥� + i + 鈥�,j=鈥� + j);聽 聽 聽 聽 聽 聽 聽 if(j == 5) break ok;聽 聽 聽 聽 }}鍙﹀锛屾垜涓汉閫氬父骞朵笉浣跨敤鏍囧彿杩欑鏂瑰紡锛岃�屾槸璁╁灞傜殑寰幆鏉′欢琛ㄨ揪寮忕殑缁撴灉鍙互鍙楀埌閲屽眰寰幆浣撲唬鐮佺殑鎺у埗锛屼緥濡傦紝瑕佸湪浜岀淮鏁扮粍涓煡鎵惧埌鏌愪釜鏁板瓧銆俰nt arr[][] ={{1,2,3},{4,5,6,7},{9}};boolean found = false;for(int i=0;i78锛�"def" ---> 62锛�"xyz" ---> 65鍦╤ashSet涓殑瀛樺偍椤哄簭涓嶆槸62,65,78銆侺inkedHashSet鎸夋彃鍏ョ殑椤哄簭瀛樺偍锛岄偅琚瓨鍌ㄥ璞$殑hashcode鏂规硶杩樻湁浠�涔堜綔鐢ㄥ憿锛熷鍛樻兂鎯�!hashset闆嗗悎姣旇緝涓や釜瀵硅薄鏄惁鐩哥瓑锛岄鍏堢湅hashcode鏂规硶鏄惁鐩哥瓑锛岀劧鍚庣湅equals鏂规硶鏄惁鐩哥瓑銆俷ew涓や釜Student鎻掑叆鍒癏ashSet涓紝鐪婬ashSet鐨剆ize锛屽疄鐜癶ashcode鍜宔quals鏂规硶鍚庡啀鐪媠ize銆� 鍚屼竴涓璞″彲浠ュ湪Vector涓姞鍏ュ娆°�傚線闆嗗悎閲岄潰鍔犲厓绱狅紝鐩稿綋浜庨泦鍚堥噷鐢ㄤ竴鏍圭怀瀛愯繛鎺ュ埌浜嗙洰鏍囧璞°�傚線HashSet涓嵈鍔犱笉浜嗗娆$殑銆� 64銆佽鍑篈rrayList,Vector, LinkedList鐨勫瓨鍌ㄦ�ц兘鍜岀壒鎬rrayList鍜孷ector閮芥槸浣跨敤鏁扮粍鏂瑰紡瀛樺偍鏁版嵁锛屾鏁扮粍鍏冪礌鏁板ぇ浜庡疄闄呭瓨鍌ㄧ殑鏁版嵁浠ヤ究澧炲姞鍜屾彃鍏ュ厓绱狅紝瀹冧滑閮藉厑璁哥洿鎺ユ寜搴忓彿绱㈠紩鍏冪礌锛屼絾鏄彃鍏ュ厓绱犺娑夊強鏁扮粍鍏冪礌绉诲姩绛夊唴瀛樻搷浣滐紝鎵�浠ョ储寮曟暟鎹揩鑰屾彃鍏ユ暟鎹參锛孷ector鐢变簬浣跨敤浜唖ynchronized鏂规硶锛堢嚎绋嬪畨鍏級锛岄�氬父鎬ц兘涓婅緝ArrayList宸紝鑰孡inkedList浣跨敤鍙屽悜閾捐〃瀹炵幇瀛樺偍锛屾寜搴忓彿绱㈠紩鏁版嵁闇�瑕佽繘琛屽墠鍚戞垨鍚庡悜閬嶅巻锛屼絾鏄彃鍏ユ暟鎹椂鍙渶瑕佽褰曟湰椤圭殑鍓嶅悗椤瑰嵆鍙紝鎵�浠ユ彃鍏ラ�熷害杈冨揩銆� LinkedList涔熸槸绾跨▼涓嶅畨鍏ㄧ殑锛孡inkedList鎻愪緵浜嗕竴浜涙柟娉曪紝浣垮緱LinkedList鍙互琚綋浣滃爢鏍堝拰闃熷垪鏉ヤ娇鐢ㄣ��65銆佸幓鎺変竴涓猇ector闆嗗悎涓噸澶嶇殑鍏冪礌Vector newVector = new Vector();For (int i=0;io1.age?1:age1 ){聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 regex= "" + seperators[0] + "|" + seperators[1];聽 聽 聽 聽 聽 聽 聽 }else{聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 regex= "" + seperators[0];聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 words =results.split(regex);聽 聽 聽 }聽 聽 聽 聽 聽 聽 public StringnextWord(){聽 聽 聽 聽 聽 聽 聽 if(pos ==words.length)聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 returnnull;聽 聽 聽 聽 聽 聽 聽 returnwords[pos++];聽 聽 聽 } } 2銆佺紪鍐欎竴涓▼搴忥紝灏哾:\java鐩綍涓嬬殑鎵�鏈�.java鏂囦欢澶嶅埗鍒癲:\jad鐩綍涓嬶紝骞跺皢鍘熸潵鏂囦欢鐨勬墿灞曞悕浠�.java鏀逛负.jad銆傦紙澶у姝e湪鍋氫笂闈㈣繖閬撻锛岀綉涓婅繜鍒扮殑鏈嬪弸涔熻鍋氬仛杩欓亾棰橈紝鎵惧伐浣滃繀椤昏兘缂栧啓杩欎簺绠�鍗曢棶棰樼殑浠g爜锛侊級绛旓細listFiles鏂规硶鎺ュ彈涓�涓狥ileFilter瀵硅薄锛岃繖涓狥ileFilter瀵硅薄灏辨槸杩囪檻鐨勭瓥鐣ュ璞★紝涓嶅悓鐨勪汉鎻愪緵涓嶅悓鐨凢ileFilter瀹炵幇锛屽嵆鎻愪緵浜嗕笉鍚岀殑杩囨护绛栫暐銆俰mport java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.FilenameFilter;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream; public class Jad2Java {聽 聽 聽 聽 public static voidmain(String[] args) throws Exception {聽 聽 聽 聽 聽 聽 聽 File srcDir =new File("java");聽 聽 聽 聽 聽 聽 聽 if(!(srcDir.exists()&& srcDir.isDirectory()))聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 thrownew Exception("鐩綍涓嶅瓨鍦�");聽 聽 聽 聽 聽 聽 聽 File[] files= srcDir.listFiles(聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 newFilenameFilter(){聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 publicboolean accept(File dir, String name) {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 returnname.endsWith(".java");聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 );聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 System.out.println(files.length);聽 聽 聽 聽 聽 聽 聽 File destDir= new File("jad");聽 聽 聽 聽 聽 聽 聽 if(!destDir.exists())destDir.mkdir();聽 聽 聽 聽 聽 聽 聽 for(File f:files){聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 FileInputStream聽 fis = new FileInputStream(f);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 StringdestFileName = f.getName().replaceAll("\\.java$", ".jad");聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 FileOutputStreamfos = new FileOutputStream(new File(destDir,destFileName));聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 copy(fis,fos);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 fis.close();聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 fos.close();聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 }聽 聽 聽 聽 聽 聽 private static voidcopy(InputStream ips,OutputStream ops) throws Exception{聽 聽 聽 聽 聽 聽 聽 int len = 0;聽 聽 聽 聽 聽 聽 聽 byte[] buf =new byte[1024];聽 聽 聽 聽 聽 聽 聽 while((len =ips.read(buf)) != -1){聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ops.write(buf,0,len);聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 }} 鐢辨湰棰樻�荤粨鐨勬�濇兂鍙婄瓥鐣ユā寮忕殑瑙f瀽锛�1.class jad2java{聽 聽 聽 1. 寰楀埌鏌愪釜鐩綍涓嬬殑鎵�鏈夌殑java鏂囦欢闆嗗悎聽 聽 聽 聽 聽 聽 聽 1.1 寰楀埌鐩綍 File srcDir = newFile("d:\\java");聽 聽 聽 聽 聽 聽 聽 1.2 寰楀埌鐩綍涓嬬殑鎵�鏈塲ava鏂囦欢锛欶ile[] files =srcDir.listFiles(new MyFileFilter());聽 聽 聽 聽 聽 聽 聽 1.3 鍙兂寰楀埌.java鐨勬枃浠讹細 class MyFileFilterimplememyts FileFilter{聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 publicboolean accept(File pathname){聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 returnpathname.getName().endsWith(".java")聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 2.灏嗘瘡涓枃浠跺鍒跺埌鍙﹀涓�涓洰褰曪紝骞舵敼鎵╁睍鍚嵚� 聽 聽 聽 聽 聽 聽 2.1 寰楀埌鐩爣鐩綍锛屽鏋滅洰鏍囩洰褰曚笉瀛樺湪锛屽垯鍒涘缓涔嬄� 聽 聽 聽 聽 聽 聽 2.2 鏍规嵁婧愭枃浠跺悕寰楀埌鐩爣鏂囦欢鍚嶏紝娉ㄦ剰瑕佺敤姝e垯琛ㄨ揪寮忥紝娉ㄦ剰.鐨勮浆涔夈�偮� 聽 聽 聽 聽 聽 聽 2.3 鏍规嵁琛ㄧず鐩綍鐨凢ile鍜岀洰鏍囨枃浠跺悕鐨勫瓧绗︿覆锛屽緱鍒拌〃绀虹洰鏍囨枃浠剁殑File銆偮� 聽 聽 聽 聽 聽 聽 聽 聽 聽 //瑕佸湪纭洏涓噯纭湴鍒涘缓鍑轰竴涓枃浠讹紝闇�瑕佺煡閬撴枃浠跺悕鍜屾枃浠剁殑鐩綍銆偮� 聽 聽 聽 聽 聽 聽 2.4 灏嗘簮鏂囦欢鐨勬祦鎷疯礉鎴愮洰鏍囨枃浠舵祦锛屾嫹璐濇柟娉曠嫭绔嬫垚涓轰竴涓柟娉曪紝鏂规硶鐨勫弬鏁伴噰鐢ㄦ娊璞℃祦鐨勫舰寮忋�偮� 聽 聽 聽 聽 聽 聽 聽 聽 聽 //鏂规硶鎺ュ彈鐨勫弬鏁扮被鍨嬪敖閲忛潰鍚戠埗绫伙紝瓒婃娊璞¤秺濂斤紝杩欐牱閫傚簲闈㈡洿瀹藉箍銆� } 鍒嗘瀽listFiles鏂规硶鍐呴儴鐨勭瓥鐣ユā寮忓疄鐜板師鐞咶ile[] listFiles(FileFilter filter){聽 聽 聽 File[] files =listFiles();聽 聽 聽 //ArraylistacceptedFilesList = new ArrayList();聽 聽 聽 File[] acceptedFiles= new File[files.length];聽 聽 聽 int pos = 0;聽 聽 聽 for(File file:files){聽 聽 聽 聽 聽 聽 聽 booleanaccepted = filter.accept(file);聽 聽 聽 聽 聽 聽 聽 if(accepted){聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //acceptedFilesList.add(file);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 acceptedFiles[pos++]= file;聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 Arrays.copyOf(acceptedFiles,pos);聽 聽 聽 //return(File[])accpetedFilesList.toArray();聽 聽 聽 }3銆佺紪鍐欎竴涓埅鍙栧瓧绗︿覆鐨勫嚱鏁帮紝杈撳叆涓轰竴涓瓧绗︿覆鍜屽瓧鑺傛暟锛岃緭鍑轰负鎸夊瓧鑺傛埅鍙栫殑瀛楃涓诧紝浣嗚淇濊瘉姹夊瓧涓嶈鎴彇鍗婁釜锛屽鈥滄垜ABC鈥濓紝4锛屽簲璇ユ埅鍙栤�滄垜AB鈥濓紝杈撳叆鈥滄垜ABC姹塂EF鈥濓紝6锛屽簲璇ヨ緭鍑衡�滄垜ABC鈥濓紝鑰屼笉鏄�滄垜ABC+姹夌殑鍗婁釜鈥濄�傜瓟锛毬� 聽 聽 棣栧厛瑕佷簡瑙d腑鏂囧瓧绗︽湁澶氱缂栫爜鍙婂悇绉嶇紪鐮佺殑鐗瑰緛銆偮� 聽 鍋囪n涓鸿鎴彇鐨勫瓧鑺傛暟銆偮� 聽 聽 public static voidmain(String[] args) throws Exception{聽 聽 聽 聽 聽 聽 聽 String str ="鎴慳鐖变腑鍗巃bc鎴戠埍浼犳櫤def';聽 聽 聽 聽 聽 聽 聽 String str ="鎴慉BC姹�";聽 聽 聽 聽 聽 聽 聽 int num =trimGBK(str.getBytes("GBK"),5);聽 聽 聽 聽 聽 聽 聽 System.out.println(str.substring(0,num));聽 聽 聽 }聽 聽 聽 聽 聽 聽 public staticint聽 trimGBK(byte[] buf,int n){聽 聽 聽 聽 聽 聽 聽 int num = 0;聽 聽 聽 聽 聽 聽 聽 booleanbChineseFirstHalf = false;聽 聽 聽 聽 聽 聽 聽 for(inti=0;i=鈥�0鈥�&& ch<=鈥�9鈥�)聽 聽 {聽 聽 聽 聽 digitCount++聽 聽 }聽 聽 elseif((ch>=鈥檃鈥�&& ch<=鈥檢鈥�) || (ch>=鈥橝鈥� && ch<=鈥橺鈥�))聽 聽 {聽 聽 聽 聽 engishCount++;聽 聽 }聽 聽 else聽 聽 {聽 聽 聽 聽 chineseCount++;聽 聽 }}System.out.println(鈥︹�︹�︹�︹��); 5銆佽鏄庣敓娲讳腑閬囧埌鐨勪簩鍙夋爲锛岀敤java瀹炵幇浜屽弶鏍戣繖鏄粍鍚堣璁℃ā寮忋�傛垜鏈夊緢澶氫釜(鍋囪10涓囦釜)鏁版嵁瑕佷繚瀛樿捣鏉ワ紝浠ュ悗杩橀渶瑕佷粠淇濆瓨鐨勮繖浜涙暟鎹腑妫�绱㈡槸鍚﹀瓨鍦ㄦ煇涓暟鎹紝锛堟垜鎯宠鍑轰簩鍙夋爲鐨勫ソ澶勶紝璇ユ�庝箞璇村憿锛熼偅灏辨槸璇村埆浜虹殑缂虹偣锛夛紝鍋囧瀛樺湪鏁扮粍涓紝閭d箞锛岀宸ц鎵剧殑鏁板瓧浣嶄簬99999閭d釜鍦版柟锛岄偅鏌ユ壘鐨勯�熷害灏嗗緢鎱紝鍥犱负瑕佷粠绗�1涓緷娆″線鍚庡彇锛屽彇鍑烘潵鍚庤繘琛屾瘮杈冦�傚钩琛′簩鍙夋爲锛堟瀯寤哄钩琛′簩鍙夋爲闇�瑕佸厛鎺掑簭锛屾垜浠繖閲屽氨涓嶄綔鑰冭檻浜嗭級鍙互寰堝ソ鍦拌В鍐宠繖涓棶棰橈紝浣嗕簩鍙夋爲鐨勯亶鍘嗭紙鍓嶅簭锛屼腑搴忥紝鍚庡簭锛夋晥鐜囪姣旀暟缁勪綆寰堝锛屽師鐞嗗涓嬪浘锛氫唬鐮佸涓嬶細package com.huawei.interview; publicclass Node {聽 聽 public int value;聽 聽 public Node left;聽 聽 public Node right;聽 聽 聽 public void store(intvalue)聽 聽 {聽 聽 聽 if(valuethis.value)聽 聽 聽 {聽 聽 聽 聽 聽 if(right ==null)聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 right = new Node();聽 聽 聽 聽 聽 聽 聽 right.value=value;聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 else聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 right.store(value);聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 }聽 聽 聽 public boolean find(intvalue)聽 聽 {聽 聽 聽 聽 System.out.println("happen" +this.value);聽 聽 聽 if(value ==this.value)聽 聽 聽 {聽 聽 聽 聽 聽 return true;聽 聽 聽 }聽 聽 聽 else if(value>this.value)聽 聽 聽 {聽 聽 聽 聽 聽 if(right ==null)returnfalse;聽 聽 聽 聽 聽 return right.find(value);聽 聽 聽 }else聽 聽 聽 {聽 聽 聽 聽 聽 if(left ==null)returnfalse;聽 聽 聽 聽 聽 return left.find(value);聽 聽 聽 }聽 聽 }聽 聽 聽 public聽 void preList()聽 聽 {聽 聽 聽 System.out.print(this.value+ ",");聽 聽 聽 if(left!=null)left.preList();聽 聽 聽 if(right!=null) right.preList();聽 聽 }聽 聽 聽 public void middleList()聽 聽 {聽 聽 聽 if(left!=null)left.preList();聽 聽 聽 System.out.print(this.value+ ",");聽 聽 聽 if(right!=null)right.preList();聽 聽 聽 聽 聽 }聽 聽 public void afterList()聽 聽 {聽 聽 聽 if(left!=null)left.preList();聽 聽 聽 if(right!=null)right.preList();聽 聽 聽 System.out.print(this.value+ ",");聽 聽 聽 聽 聽 }聽 聽 聽 public static voidmain(String [] args)聽 聽 {聽 聽 聽 int [] data =new int[20];聽 聽 聽 for(inti=0;ithis.value)聽 聽 聽 {聽 聽 聽 聽 聽 if(right != null)聽 聽 聽 聽 聽 聽 聽 right.add(value);聽 聽 聽 聽 聽 else聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 Node node = new Node(value);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 right = node;聽 聽 聽 聽 聽 }聽 聽 聽 }聽 聽 聽 else{聽 聽 聽 聽 聽 if(left != null)聽 聽 聽 聽 聽 聽 聽 left.add(value);聽 聽 聽 聽 聽 else聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 Node node = new Node(value);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 left = node;聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 }聽 聽 聽 public boolean find(int value){聽 聽 聽 if(value == this.value) return true;聽 聽 聽 else if(value > this.value){聽 聽 聽 聽 聽 if(right == null) return false;聽 聽 聽 聽 聽 else return right.find(value);聽 聽 聽 }else{聽 聽 聽 聽 聽 if(left == null) return false;聽 聽 聽 聽 聽 else return left.find(value);聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 }聽 聽 聽 public void display(){聽 聽 聽 System.out.println(value);聽 聽 聽 if(left != null) left.display();聽 聽 聽 if(right != null) right.display();聽 聽 聽 聽 聽 }聽 聽 聽 /*public Iterator iterator(){聽 聽 聽 聽 聽 }*/聽 聽 聽 public static void main(String[] args){聽 聽 聽 int[] values = new int[8];聽 聽 聽 for(int i=0;i<8;i++){聽 聽 聽 聽 聽 int num = (int)(Math.random() * 15);聽 聽 聽 聽 聽 //System.out.println(num);聽 聽 聽 聽 聽 //if(Arrays.binarySearch(values,num)<0)聽 聽 聽 聽 聽 if(!contains(values,num))聽 聽 聽 聽 聽 聽 聽 values[i] = num;聽 聽 聽 聽 聽 else聽 聽 聽 聽 聽 聽 聽 i--;聽 聽 聽 }聽 聽 聽 聽 聽 聽 System.out.println(Arrays.toString(values));聽 聽 聽 聽 聽 聽 Node root = new Node(values[0]);聽 聽 聽 for(int i=1;iuser2.value)聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 return 1;聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }else聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 returnuser1.name.compareTo(user2.name);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 );聽 聽 聽 Iterator iterator =results.keySet().iterator();聽 聽 聽 while(iterator.hasNext())聽 聽 聽 {聽 聽 聽 聽 聽 String name = (String)iterator.next();聽 聽 聽 聽 聽 Integer value =(Integer)results.get(name);聽 聽 聽 聽 聽 if(value > 1)聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 sortedResults.add(newUser(name,value));聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 }聽 聽 聽 聽 聽 聽 printResults(sortedResults);聽 聽 }聽 聽 private static voidprintResults(TreeSet sortedResults)聽 聽 {聽 聽 聽 Iterator iterator聽 = sortedResults.iterator();聽 聽 聽 while(iterator.hasNext())聽 聽 聽 {聽 聽 聽 聽 聽 User user = (User)iterator.next();聽 聽 聽 聽 聽 System.out.println(user.name +":" + user.value);聽 聽 聽 }聽 聽 聽 }聽 聽 public static voiddealLine(String line,Map map)聽 聽 {聽 聽 聽 if(!"".equals(line.trim()))聽 聽 聽 {聽 聽 聽 聽 聽 String [] results =line.split(",");聽 聽 聽 聽 聽 if(results.length == 3)聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 String name = results[1];聽 聽 聽 聽 聽 聽 聽 Integer value =(Integer)map.get(name);聽 聽 聽 聽 聽 聽 聽 if(value ==null)value = 0;聽 聽 聽 聽 聽 聽 聽 map.put(name,value + 1);聽 聽 聽 聽 聽 }聽 聽 聽 }聽 聽 } }7銆佸啓涓�涓猄ingleton鍑烘潵銆傜涓�绉嶏細楗辨眽妯″紡public classSingleTon {聽 聽 private SingleTon(){聽 聽 聽 }聽 聽 //瀹炰緥鍖栨斁鍦ㄩ潤鎬佷唬鐮佸潡閲屽彲鎻愰珮绋嬪簭鐨勬墽琛屾晥鐜囷紝浣嗕篃鍙兘鏇村崰鐢ㄧ┖闂绰� 聽 聽 private final static SingleTon instance =new SingleTon();聽 聽 public static SingleTon getInstance(){聽 聽 聽 return instance;聽 聽 }} 绗簩绉嶏細楗ユ眽妯″紡public classSingleTon {聽 聽 private SingleTon(){}聽 聽 聽 private static instance = null;//newSingleTon();聽 聽 聽 public static synchronized SingleTongetInstance(){聽 聽 聽 if(instance == null)聽 聽 聽 聽 聽 instance = new SingleTon();聽 聽 聽 return instance;聽 聽 }} 绗笁绉嶏細鐢ㄦ灇涓韭� 聽 public enum SingleTon{聽 聽 聽 ONE;聽 聽 聽 } 绗笁锛氭洿瀹為檯鐨勫簲鐢紙鍦ㄤ粈涔堟儏鍐电敤鍗曚緥锛塸ublic classSequenceGenerator{聽 聽 //涓嬮潰鏄绫昏嚜韬殑涓氬姟鍔熻兘浠g爜聽 聽 private int count = 0;聽 聽 public synchronized int getSequence(){聽 聽 聽 ++count;聽 聽 }聽 聽 聽 //涓嬮潰鏄妸璇ョ被鍙樻垚鍗曚緥鐨勪唬鐮伮� 聽 private SequenceGenerator(){}聽 聽 private final static instance = newSequenceGenerator();聽 聽 public static SingleTon getInstance(){聽 聽 聽 return instance;聽 聽 }聽 聽 } 绗洓锛毬� 聽 public class MemoryDao聽 聽 {聽 聽 private HashMap map = new HashMap();聽 聽 聽 publicvoid add(Student stu1){聽 聽 聽 聽 聽 聽 map.put(SequenceGenerator.getInstance().getSequence(),stu1);聽 聽 }聽 聽 //鎶奙emoryDao鍙樻垚鍗曚緥聽 }聽 聽 聽 Singleton妯″紡涓昏浣滅敤鏄繚璇佸湪Java搴旂敤绋嬪簭涓紝涓�涓被Class鍙湁涓�涓疄渚嬪瓨鍦ㄣ�備竴鑸琒ingleton妯″紡閫氬父鏈夊嚑绉嶇褰㈠紡:绗竴绉嶅舰寮�: 瀹氫箟涓�涓被锛屽畠鐨勬瀯閫犲嚱鏁颁负private鐨勶紝瀹冩湁涓�涓猻tatic鐨刾rivate鐨勮绫诲彉閲忥紝鍦ㄧ被鍒濆鍖栨椂瀹炰緥璇濓紝閫氳繃涓�涓猵ublic鐨刧etInstance鏂规硶鑾峰彇瀵瑰畠鐨勫紩鐢�,缁ц�岃皟鐢ㄥ叾涓殑鏂规硶銆俻ublic class Singleton {private Singleton(){}聽 聽 //鍦ㄨ嚜宸卞唴閮ㄥ畾涔夎嚜宸变竴涓疄渚嬶紝鏄笉鏄緢濂囨�紵聽 聽 //娉ㄦ剰杩欐槸private鍙緵鍐呴儴璋冪敤聽 聽 private staticSingleton instance = new Singleton();聽 聽 //杩欓噷鎻愪緵浜嗕竴涓緵澶栭儴璁块棶鏈琧lass鐨勯潤鎬佹柟娉曪紝鍙互鐩存帴璁块棶銆�銆�聽 聽 public staticSingleton getInstance() {聽 聽 return instance;聽 聽 }聽 }聽 绗簩绉嶅舰寮�:public class Singleton {private static Singleton instance = null;public static synchronized Singleton getInstance() {//杩欎釜鏂规硶姣斾笂闈㈡湁鎵�鏀硅繘锛屼笉鐢ㄦ瘡娆¢兘杩涜鐢熸垚瀵硅薄锛屽彧鏄涓�娆°��銆�銆�//浣跨敤鏃剁敓鎴愬疄渚嬶紝鎻愰珮浜嗘晥鐜囷紒if (instance==null)instance锛漬ew Singleton();聽 聽 聽 聽 聽 聽 聽 return instance;聽 }}鍏朵粬褰㈠紡:瀹氫箟涓�涓被锛屽畠鐨勬瀯閫犲嚱鏁颁负private鐨勶紝鎵�鏈夋柟娉曚负static鐨勩�備竴鑸涓虹涓�绉嶅舰寮忚鏇村姞瀹夊叏浜�8銆侀�掑綊绠楁硶棰�1涓�涓暣鏁帮紝澶т簬0锛屼笉鐢ㄥ惊鐜拰鏈湴鍙橀噺锛屾寜鐓锛�2n锛�4n锛�8n鐨勯『搴忛�掑锛屽綋鍊煎ぇ浜�5000鏃讹紝鎶婂�兼寜鐓ф寚瀹氶『搴忚緭鍑烘潵銆備緥锛歯=1237鍒欒緭鍑轰负锛�1237锛�2474锛�4948锛�9896锛�9896锛�4948锛�2474锛�1237锛屾彁绀猴細鍐欑▼搴忔椂锛屽厛鑷磋阿鎸夐�掑鏂瑰紡鐨勪唬鐮侊紝鍐欏ソ閫掑鐨勪互鍚庯紝鍐嶅鍔犺�冭檻閫掑噺閮ㄥ垎銆偮� 聽 public static void doubleNum(int n)聽 聽 {聽 聽 聽 System.out.println(n);聽 聽 聽 if(n<=5000)聽 聽 聽 聽 聽 doubleNum(n*2);聽 聽 聽 System.out.println(n);聽 聽 聽 聽 }Gaibaota(N) = Gaibaota(N-1) + n聽 9銆侀�掑綊绠楁硶棰�2绗�1涓汉10锛岀2涓瘮绗�1涓汉澶�2宀侊紝渚濇閫掓帹锛岃鐢ㄩ�掑綊鏂瑰紡璁$畻鍑虹8涓汉澶氬ぇ锛焢ackage cn.itcast; import java.util.Date; publicclass A1 {聽 聽 public static voidmain(String [] args)聽 聽 {聽 聽 聽 System.out.println(computeAge(8));聽 聽 }聽 聽 聽 public static int computeAge(intn)聽 聽 {聽 聽 聽 if(n==1)return 10;聽 聽 聽 returncomputeAge(n-1) + 2;聽 聽 }}聽 聽 public static voidtoBinary(int n,StringBuffer result)聽 聽 {聽 聽 聽 聽 if(n/2 != 0)聽 聽 聽 聽 聽 toBinary(n/2,result);聽 聽 聽 result.append(n%2);聽 聽 聽 聽 }10銆佹帓搴忛兘鏈夊摢鍑犵鏂规硶锛熻鍒椾妇銆傜敤JAVA瀹炵幇涓�涓揩閫熸帓搴忋�� 鏈汉鍙爺绌惰繃鍐掓场鎺掑簭銆侀�夋嫨鎺掑簭鍜屽揩閫熸帓搴忥紝涓嬮潰鏄揩閫熸帓搴忕殑浠g爜锛歱ublic class QuickSort {/*** 蹇�熸帓搴�* @param strDate* @param left* @param right*/public void quickSort(String[] strDate,int left,int right){String middle,tempDate;int i,j;i=left;j=right;middle=strDate[(i+j)/2];do{while(strDate[i].compareTo(middle)<0&& i0&& j>left)j--; //鎵惧嚭鍙宠竟姣斾腑闂村�煎皬鐨勬暟if(i<=j){ //灏嗗乏杈瑰ぇ鐨勬暟鍜屽彸杈瑰皬鐨勬暟杩涜鏇挎崲tempDate=strDate[i];strDate[i]=strDate[j];strDate[j]=tempDate;i++;j--;}}while(i<=j); //褰撲袱鑰呬氦閿欐椂鍋滄if(ileft){quickSort(strDate,left,j);}}/**聽 * @param args聽 */public static void main(String[] args){String[] strVoid=newString[]{"11","66","22","0","55","22","0","32"};QuickSort sort=new QuickSort();sort.quickSort(strVoid,0,strVoid.length-1);for(int i=0;i锛堜竴鍗冮浂涓�鎷句竴鍏冩暣锛夎緭鍑恒�傚幓闆剁殑浠g爜锛毬� 聽 returnsb.reverse().toString().replaceAll("闆禰鎷句桨浠焆","闆�").replaceAll("闆�+涓�","涓�").replaceAll("闆�+鍏�","鍏�").replaceAll("闆�+","闆�"); public class RenMingBi {聽 聽 聽 聽 /**聽 聽 聽 聽 * @param args add by zxx ,Nov 29, 2008聽 聽 聽 聽 */聽 聽 聽 private static finalchar[] data = new char[]{聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 '闆�','澹�','璐�','鍙�','鑲�','浼�','闄�','鏌�','鎹�','鐜�'聽 聽 聽 聽 聽 聽 聽 };聽 聽 聽 private static finalchar[] units = new char[]{聽 聽 聽 聽 聽 聽 聽 '鍏�','鎷�','浣�','浠�','涓�','鎷�','浣�','浠�','浜�'聽 聽 聽 };聽 聽 聽 public static voidmain(String[] args) {聽 聽 聽 聽 聽 聽 聽 // TODOAuto-generated method stub聽 聽 聽 聽 聽 聽 聽 System.out.println(聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 convert(135689123));聽 聽 聽 }聽 聽 聽 聽 public static Stringconvert(int money)聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 StringBuffersbf = new StringBuffer();聽 聽 聽 聽 聽 聽 聽 int unit = 0;聽 聽 聽 聽 聽 聽 聽 while(money!=0)聽 聽 聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 sbf.insert(0,units[unit++]);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 intnumber = money%10;聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 sbf.insert(0,data[number]);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 money/= 10;聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 returnsbf.toString();聽 聽 聽 }}涓�. html&JavaScript&ajax閮ㄥ垎1. 鍒ゆ柇绗簩涓棩鏈熸瘮绗竴涓棩鏈熷ぇ聽 聽 聽 濡備綍鐢ㄨ剼鏈垽鏂敤鎴疯緭鍏ョ殑鐨勫瓧绗︿覆鏄笅闈㈢殑鏃堕棿鏍煎紡2004-11-21蹇呴』瑕佷繚璇佺敤鎴风殑杈撳叆鏄鏍煎紡锛屽苟涓旀槸鏃堕棿锛屾瘮濡傝鏈堜唤涓嶅ぇ浜�12绛夌瓑锛屽彟澶栨垜闇�瑕佺敤鎴疯緭鍏ヤ袱涓紝骞朵笖鍚庝竴涓姣斿墠涓�涓櫄锛屽彧鍏佽鐢↗AVASCRIPT锛岃璇︾粏甯姪浣滅瓟锛�,//杩欓噷鍙敤姝e垯琛ㄨ揪寮忓垽鏂彁鍓嶅垽鏂竴涓嬫牸寮忥紝鐒跺悗鎸変笅鎻愬彇鍚勬椂闂村瓧娈靛唴瀹箇indow.onload =function()
{
//杩欎箞鍐欐槸涓轰簡瀹炵幇js浠g爜涓巋tml浠g爜鐨勫垎绂伙紝褰撴垜淇敼js鏃讹紝涓嶈兘褰卞搷html浠g爜銆�
document.getElementById("frm1").onsubmit=
function(){
vard1 = this.d1.value;
vard2 = this.d2.value;
if(!verifyDate(d1)) {alert("绗竴涓棩鏈熸牸寮忎笉瀵�");return false;}
if(!verifyDate(d2)) {alert("绗簩涓棩鏈熸牸寮忎笉瀵�");return false;}
if(!compareDate(d1,d2)){alert("绗簩涓棩鏈熸瘮绗竴鏃ユ湡灏�");return false;}
};
}
functioncompareDate(d1,d2)
{
var arrayD1= d1.split("-");
var date1 =new Date(arrayD1[0],arrayD1[1],arrayD1[2]);
var arrayD2= d2.split("-");
var date2 =new Date(arrayD2[0],arrayD2[1],arrayD2[2]);
if(date1> date2) return false;
return true;
}
functionverifyDate(d)
{
vardatePattern = /^\d{4}-(0?[1-9]|1[0-2])-(0?[1-9]|[1-2]\d|3[0-1])$/;
returndatePattern.test(d);
}
2. 鐢╰able鏄剧ずn鏉¤褰曪紝姣�3琛屾崲涓�娆¢鑹诧紝鍗�1锛�2锛�3鐢ㄧ孩鑹插瓧浣擄紝4锛�5锛�6鐢ㄧ豢鑹插瓧浣擄紝7锛�8锛�9鐢ㄧ孩棰滆壊瀛椾綋銆�
1
2
3
4
5
6
7
8
9
10
window.onload=function()
{
var tbl =document.getElementById("tbl");
rows =tbl.getElementsByTagName("tr");
for(i=0;i
{
var j= parseInt(i/3);
if(j%2==0)rows[i].style.backgroundColor="#f00";
else聽 rows[i].style.backgroundColor="#0f0";
}
}3銆丠TML鐨� form鎻愪氦涔嬪墠濡備綍楠岃瘉鏁板�兼枃鏈鐨勫唴瀹瑰叏閮ㄤ负鏁板瓧?鍚﹀垯鐨勮瘽鎻愮ず鐢ㄦ埛骞剁粓姝㈡彁浜�?
function chkForm(this)聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 var value = thist.d1.value;聽 聽 聽 聽 聽 聽 聽 var len =value.length;聽 聽 聽 聽 聽 聽 聽 for(vari=0;i"9"|| value.charAt(i)<"0")聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 alert("鍚湁闈炴暟瀛楀瓧绗�");聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 returnfalse;聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 return true;聽 聽 聽 } 4銆佽鍐欏嚭鐢ㄤ簬鏍¢獙HTML鏂囨湰妗嗕腑杈撳叆鐨勫唴瀹瑰叏閮ㄤ负鏁板瓧鐨刯avascript浠g爜function chkNumber(eleText)聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 var value =eleText.value;聽 聽 聽 聽 聽 聽 聽 var len =value.length;聽 聽 聽 聽 聽 聽 聽 for(vari=0;i"9"|| value.charAt(i)<"0")聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 alert("鍚湁闈炴暟瀛楀瓧绗�");聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 eleText.focus();聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 break;聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 }闄や簡鍐欏畬浠g爜锛岃繕搴旇鍦ㄧ綉椤典笂鍐欏嚭瀹為獙姝ラ鍜屽湪浠g爜涓姞鍏ュ疄鐜版�濊矾锛岃闈㈣瘯瀹樹竴鐪嬪氨鏄庣櫧浣犵殑鎰忓浘鍜屾鏌ヤ綘鐨勭粨鏋溿�� 5銆佽璇翠綘鐢ㄨ繃閭d簺ajax鎶�鏈拰妗嗘灦锛岃璇村畠浠殑鍖哄埆 鍥�. Java web閮ㄥ垎1銆乀omcat鐨勪紭鍖栫粡楠岀瓟:鍘绘帀瀵箇eb.xml鐨勭洃瑙嗭紝鎶妀sp鎻愬墠缂栬緫鎴怱ervlet銆傛湁瀵屼綑鐗╃悊鍐呭瓨鐨勬儏鍐碉紝鍔犲ぇtomcat浣跨敤鐨刯vm鐨勫唴瀛樎� 2銆丠TTP璇锋眰鐨凣ET涓嶱OST鏂瑰紡鐨勫尯鍒瓟:servlet鏈夎壇濂界殑鐢熷瓨鏈熺殑瀹氫箟锛屽寘鎷姞杞藉拰瀹炰緥鍖栥�佸垵濮嬪寲銆佸鐞嗚姹備互鍙婃湇鍔$粨鏉熴�傝繖涓敓瀛樻湡鐢眏avax.servlet.Servlet鎺ュ彛鐨刬nit,service鍜宒estroy鏂规硶琛ㄨ揪銆�3銆佽В閲婁竴涓嬩粈涔堟槸servlet;绛�:servlet鏈夎壇濂界殑鐢熷瓨鏈熺殑瀹氫箟锛屽寘鎷姞杞藉拰瀹炰緥鍖栥�佸垵濮嬪寲銆佸鐞嗚姹備互鍙婃湇鍔$粨鏉熴�傝繖涓敓瀛樻湡鐢眏avax.servlet.Servlet鎺ュ彛鐨刬nit,service鍜宒estroy鏂规硶琛ㄨ揪銆�4銆佽涓�璇碨ervlet鐨勭敓鍛藉懆鏈�?绛�:servlet鏈夎壇濂界殑鐢熷瓨鏈熺殑瀹氫箟锛屽寘鎷姞杞藉拰瀹炰緥鍖栥�佸垵濮嬪寲銆佸鐞嗚姹備互鍙婃湇鍔$粨鏉熴�傝繖涓敓瀛樻湡鐢眏avax.servlet.Servlet鎺ュ彛鐨刬nit,service鍜宒estroy鏂规硶琛ㄨ揪銆� Servlet琚湇鍔″櫒瀹炰緥鍖栧悗锛屽鍣ㄨ繍琛屽叾init鏂规硶锛岃姹傚埌杈炬椂杩愯鍏秙ervice鏂规硶锛宻ervice鏂规硶鑷姩娲鹃仯杩愯涓庤姹傚搴旂殑doXXX鏂规硶锛坉oGet锛宒oPost锛夌瓑锛屽綋鏈嶅姟鍣ㄥ喅瀹氬皢瀹炰緥閿�姣佺殑鏃跺�欒皟鐢ㄥ叾destroy鏂规硶銆倃eb瀹瑰櫒鍔犺浇servlet锛岀敓鍛藉懆鏈熷紑濮嬨�傞�氳繃璋冪敤servlet鐨刬nit()鏂规硶杩涜servlet鐨勫垵濮嬪寲銆傞�氳繃璋冪敤service()鏂规硶瀹炵幇锛屾牴鎹姹傜殑涓嶅悓璋冪敤涓嶅悓鐨刣o***()鏂规硶銆傜粨鏉熸湇鍔★紝web瀹瑰櫒璋冪敤servlet鐨刣estroy()鏂规硶銆� 5銆丼ervlet鐨勫熀鏈灦鏋刾ublic class ServletName extends HttpServlet {public void doPost(HttpServletRequest request,HttpServletResponse response) throwsServletException, IOException {}public void doGet(HttpServletRequest request,HttpServletResponse response) throwsServletException, IOException {}}6銆丼ERVLET API涓璮orward()涓巖edirect()鐨勫尯鍒紵绛�:鍓嶈�呬粎鏄鍣ㄤ腑鎺у埗鏉冪殑杞悜锛屽湪瀹㈡埛绔祻瑙堝櫒鍦板潃鏍忎腑涓嶄細鏄剧ず鍑鸿浆鍚戝悗鐨勫湴鍧�锛涘悗鑰呭垯鏄畬鍏ㄧ殑璺宠浆锛屾祻瑙堝櫒灏嗕細寰楀埌璺宠浆鐨勫湴鍧�锛屽苟閲嶆柊鍙戦�佽姹傞摼鎺ャ�傝繖鏍凤紝浠庢祻瑙堝櫒鐨勫湴鍧�鏍忎腑鍙互鐪嬪埌璺宠浆鍚庣殑閾炬帴鍦板潃銆傛墍浠ワ紝鍓嶈�呮洿鍔犻珮鏁堬紝鍦ㄥ墠鑰呭彲浠ユ弧瓒抽渶瑕佹椂锛屽敖閲忎娇鐢╢orward()鏂规硶锛屽苟涓旓紝杩欐牱涔熸湁鍔╀簬闅愯棌瀹為檯鐨勯摼鎺ャ�傚湪鏈変簺鎯呭喌涓嬶紝姣斿锛岄渶瑕佽烦杞埌涓�涓叾瀹冩湇鍔″櫒涓婄殑璧勬簮锛屽垯蹇呴』浣跨敤sendRedirect()鏂规硶銆� 7銆佷粈涔堟儏鍐典笅璋冪敤doGet()鍜宒oPost()锛烰sp椤甸潰涓殑FORM鏍囩閲岀殑method灞炴�т负get鏃惰皟鐢╠oGet()锛屼负post鏃惰皟鐢╠oPost()銆� 8銆丷equest瀵硅薄鐨勪富瑕佹柟娉曪細setAttribute(String name,Object)锛氳缃悕瀛椾负name鐨剅equest鐨勫弬鏁板�糶etAttribute(String name)锛氳繑鍥炵敱name鎸囧畾鐨勫睘鎬у�糶etAttributeNames()锛氳繑鍥瀝equest瀵硅薄鎵�鏈夊睘鎬х殑鍚嶅瓧闆嗗悎锛岀粨鏋滄槸涓�涓灇涓剧殑瀹炰緥getCookies()锛氳繑鍥炲鎴风鐨勬墍鏈塁ookie瀵硅薄锛岀粨鏋滄槸涓�涓狢ookie鏁扮粍getCharacterEncoding()锛氳繑鍥炶姹備腑鐨勫瓧绗︾紪鐮佹柟寮廹etContentLength()锛氳繑鍥炶姹傜殑Body鐨勯暱搴etHeader(String name)锛氳幏寰桯TTP鍗忚瀹氫箟鐨勬枃浠跺ご淇℃伅getHeaders(String name)锛氳繑鍥炴寚瀹氬悕瀛楃殑request Header鐨勬墍鏈夊�硷紝缁撴灉鏄竴涓灇涓剧殑瀹炰緥getHeaderNames()锛氳繑鍥炴墍浠equest Header鐨勫悕瀛楋紝缁撴灉鏄竴涓灇涓剧殑瀹炰緥getInputStream()锛氳繑鍥炶姹傜殑杈撳叆娴侊紝鐢ㄤ簬鑾峰緱璇锋眰涓殑鏁版嵁getMethod()锛氳幏寰楀鎴风鍚戞湇鍔″櫒绔紶閫佹暟鎹殑鏂规硶getParameter(String name)锛氳幏寰楀鎴风浼犻�佺粰鏈嶅姟鍣ㄧ鐨勬湁name鎸囧畾鐨勫弬鏁板�糶etParameterNames()锛氳幏寰楀鎴风浼犻�佺粰鏈嶅姟鍣ㄧ鐨勬墍鏈夊弬鏁扮殑鍚嶅瓧锛岀粨鏋滄槸涓�涓灇涓剧殑瀹炰緥getParametervalues(String name)锛氳幏寰楁湁name鎸囧畾鐨勫弬鏁扮殑鎵�鏈夊�糶etProtocol()锛氳幏鍙栧鎴风鍚戞湇鍔″櫒绔紶閫佹暟鎹墍渚濇嵁鐨勫崗璁悕绉癵etQueryString()锛氳幏寰楁煡璇㈠瓧绗︿覆getRequestURI()锛氳幏鍙栧彂鍑鸿姹傚瓧绗︿覆鐨勫鎴风鍦板潃getRemoteAddr()锛氳幏鍙栧鎴风鐨処P鍦板潃getRemoteHost()锛氳幏鍙栧鎴风鐨勫悕瀛梘etSession([Boolean create])锛氳繑鍥炲拰璇锋眰鐩稿叧SessiongetServerName()锛氳幏鍙栨湇鍔″櫒鐨勫悕瀛梘etServletPath()锛氳幏鍙栧鎴风鎵�璇锋眰鐨勮剼鏈枃浠剁殑璺緞getServerPort()锛氳幏鍙栨湇鍔″櫒鐨勭鍙e彿removeAttribute(String name)锛氬垹闄よ姹備腑鐨勪竴涓睘鎬� 9銆乫orward鍜宺edirect鐨勫尯鍒玣orward鏄湇鍔″櫒璇锋眰璧勬簮锛屾湇鍔″櫒鐩存帴璁块棶鐩爣鍦板潃鐨刄RL锛屾妸閭d釜URL鐨勫搷搴斿唴瀹硅鍙栬繃鏉ワ紝鐒跺悗鎶婅繖浜涘唴瀹瑰啀鍙戠粰娴忚鍣紝娴忚鍣ㄦ牴鏈笉鐭ラ亾鏈嶅姟鍣ㄥ彂閫佺殑鍐呭鏄粠鍝効鏉ョ殑锛屾墍浠ュ畠鐨勫湴鍧�鏍忎腑杩樻槸鍘熸潵鐨勫湴鍧�銆偮� redirect灏辨槸鏈嶅姟绔牴鎹�昏緫,鍙戦�佷竴涓姸鎬佺爜,鍛婅瘔娴忚鍣ㄩ噸鏂板幓璇锋眰閭d釜鍦板潃锛屼竴鑸潵璇存祻瑙堝櫒浼氱敤鍒氭墠璇锋眰鐨勬墍鏈夊弬鏁伴噸鏂拌姹傦紝鎵�浠ession,request鍙傛暟閮藉彲浠ヨ幏鍙栥��10銆乺equest.getAttribute()鍜� request.getParameter()鏈変綍鍖哄埆?11. jsp鏈夊摢浜涘唴缃璞�?浣滅敤鍒嗗埆鏄粈涔�?鍒嗗埆鏈変粈涔堟柟娉曪紵绛�:JSP鍏辨湁浠ヤ笅9涓唴缃殑瀵硅薄锛歳equest 鐢ㄦ埛绔姹傦紝姝よ姹備細鍖呭惈鏉ヨ嚜GET/POST璇锋眰鐨勫弬鏁皉esponse 缃戦〉浼犲洖鐢ㄦ埛绔殑鍥炲簲pageContext 缃戦〉鐨勫睘鎬ф槸鍦ㄨ繖閲岀鐞唖ession 涓庤姹傛湁鍏崇殑浼氳瘽鏈焌pplication servlet 姝e湪鎵ц鐨勫唴瀹筼ut 鐢ㄦ潵浼犻�佸洖搴旂殑杈撳嚭config聽 servlet鐨勬瀯鏋堕儴浠秔age JSP缃戦〉鏈韩exception 閽堝閿欒缃戦〉锛屾湭鎹曟崏鐨勪緥澶� request琛ㄧずHttpServletRequest瀵硅薄銆傚畠鍖呭惈浜嗘湁鍏虫祻瑙堝櫒璇锋眰鐨勪俊鎭紝骞朵笖鎻愪緵浜嗗嚑涓敤浜庤幏鍙朿ookie, header,鍜宻ession鏁版嵁鐨勬湁鐢ㄧ殑鏂规硶銆偮� response琛ㄧずHttpServletResponse瀵硅薄锛屽苟鎻愪緵浜嗗嚑涓敤浜庤缃�佸洖娴忚鍣ㄧ殑鍝嶅簲鐨勬柟娉曪紙濡俢ookies,澶翠俊鎭瓑锛壜� out瀵硅薄鏄痡avax.jsp.JspWriter鐨勪竴涓疄渚嬶紝骞舵彁渚涗簡鍑犱釜鏂规硶浣夸綘鑳界敤浜庡悜娴忚鍣ㄥ洖閫佽緭鍑虹粨鏋溿�偮� pageContext琛ㄧず涓�涓猨avax.servlet.jsp.PageContext瀵硅薄銆傚畠鏄敤浜庢柟渚垮瓨鍙栧悇绉嶈寖鍥寸殑鍚嶅瓧绌洪棿銆乻ervlet鐩稿叧鐨勫璞$殑API锛屽苟涓斿寘瑁呬簡閫氱敤鐨剆ervlet鐩稿叧鍔熻兘鐨勬柟娉曘�偮� session琛ㄧず涓�涓姹傜殑javax.servlet.http.HttpSession瀵硅薄銆係ession鍙互瀛樿串鐢ㄦ埛鐨勭姸鎬佷俊鎭� applicaton 琛ㄧず涓�涓猨avax.servle.ServletContext瀵硅薄銆傝繖鏈夊姪浜庢煡鎵炬湁鍏硈ervlet寮曟搸鍜宻ervlet鐜鐨勪俊鎭� config琛ㄧず涓�涓猨avax.servlet.ServletConfig瀵硅薄銆傝瀵硅薄鐢ㄤ簬瀛樺彇servlet瀹炰緥鐨勫垵濮嬪寲鍙傛暟銆偮� page琛ㄧず浠庤椤甸潰浜х敓鐨勪竴涓猻ervlet瀹炰緥 12. jsp鏈夊摢浜涘姩浣�?浣滅敤鍒嗗埆鏄粈涔�?锛堣繖涓棶棰樹技涔庝笉閲嶈锛屼笉鏄庣櫧涓轰綍鏈夋棰橈級绛�:JSP鍏辨湁浠ヤ笅6绉嶅熀鏈姩浣渏sp:include锛氬湪椤甸潰琚姹傜殑鏃跺�欏紩鍏ヤ竴涓枃浠躲�俲sp:useBean锛氬鎵炬垨鑰呭疄渚嬪寲涓�涓狫avaBean銆俲sp:setProperty锛氳缃甁avaBean鐨勫睘鎬с�俲sp:getProperty锛氳緭鍑烘煇涓狫avaBean鐨勫睘鎬с�俲sp:forward锛氭妸璇锋眰杞埌涓�涓柊鐨勯〉闈€�俲sp:plugin锛氭牴鎹祻瑙堝櫒绫诲瀷涓篔ava鎻掍欢鐢熸垚OBJECT鎴朎MBED鏍囪13銆丣SP鐨勫父鐢ㄦ寚浠sErrorPage(鏄惁鑳戒娇鐢‥xception瀵硅薄)锛宨sELIgnored(鏄惁蹇界暐琛ㄨ揪寮�) 14. JSP涓姩鎬両NCLUDE涓庨潤鎬両NCLUDE鐨勫尯鍒紵绛旓細鍔ㄦ�両NCLUDE鐢╦sp:include鍔ㄤ綔瀹炵幇瀹冩�绘槸浼氭鏌ユ墍鍚枃浠朵腑鐨勫彉鍖栵紝閫傚悎鐢ㄤ簬鍖呭惈鍔ㄦ�侀〉闈紝骞朵笖鍙互甯﹀弬鏁� 闈欐�両NCLUDE鐢╥nclude浼爜瀹炵幇,瀹氫笉浼氭鏌ユ墍鍚枃浠剁殑鍙樺寲锛岄�傜敤浜庡寘鍚潤鎬侀〉闈� <%@include file=included.htm %> 15銆佷袱绉嶈烦杞柟寮忓垎鍒槸浠�涔�?鏈変粈涔堝尯鍒�?锛堜笅闈㈢殑鍥炵瓟涓ラ噸閿欒锛屽簲璇ユ槸鎯抽棶forward鍜宻endRedirect鐨勫尯鍒紝姣曠珶鍑洪鐨勪汉涓嶆槸涓撲笟鎼炴枃瀛楄壓鏈殑浜猴紝鍙兘琛ㄨ揪鑳藉姏骞朵笉瑙佸緱寰堝己锛岀敤璇嶄笉涓�瀹氱簿鍑嗭紝鍔犱箣鍏惰嚜韬殑鎶�鏈潰涔熷彲鑳藉瓨鍦ㄤ竴浜涢棶棰橈紝涓嶄竴瀹氱湡姝e皢浠栫殑鎰忔�濊〃杈炬竻妤氫簡锛屼弗鏍兼剰鎬濅笂鏉ヨ锛屼竴浜涢鐩彲鑳芥牴鏈氨鏃犱汉鑳界瓟锛屾墍浠ワ紝绛旈鏃惰鎺屾彙涓诲姩锛屽彧瑕佹妸鑷繁鐭ラ亾鐨勮〃杈炬竻妤氬氨澶熶簡锛岃�屼笉瑕佸幓鎺ㄦ暡鍘熷棰樼洰鐨勫叿浣撳惈涔夋槸浠�涔堬紝涓嶈涓�鍛虫兂鐫�鏄湪绛旈锛夌瓟锛氭湁涓ょ锛屽垎鍒负锛氬墠鑰呴〉闈笉浼氳浆鍚慽nclude鎵�鎸囩殑椤甸潰锛屽彧鏄樉绀鸿椤电殑缁撴灉锛屼富椤甸潰杩樻槸鍘熸潵鐨勯〉闈€�傛墽琛屽畬鍚庤繕浼氬洖鏉ワ紝鐩稿綋浜庡嚱鏁拌皟鐢ㄣ�傚苟涓斿彲浠ュ甫鍙傛暟.鍚庤�呭畬鍏ㄨ浆鍚戞柊椤甸潰锛屼笉浼氬啀鍥炴潵銆傜浉褰撲簬go to 璇彞銆� 16銆侀〉闈㈤棿瀵硅薄浼犻�掔殑鏂规硶request锛宻ession锛宎pplication锛宑ookie绛�17銆丣SP鍜孲ervlet鏈夊摢浜涚浉鍚岀偣鍜屼笉鍚岀偣锛屼粬浠箣闂寸殑鑱旂郴鏄粈涔堬紵JSP鏄疭ervlet鎶�鏈殑鎵╁睍锛屾湰璐ㄤ笂鏄疭ervlet鐨勭畝鏄撴柟寮忥紝鏇村己璋冨簲鐢ㄧ殑澶栬〃琛ㄨ揪銆侸SP缂栬瘧鍚庢槸"绫籹ervlet"銆係ervlet鍜孞SP鏈�涓昏鐨勪笉鍚岀偣鍦ㄤ簬锛孲ervlet鐨勫簲鐢ㄩ�昏緫鏄湪Java鏂囦欢涓紝骞朵笖瀹屽叏浠庤〃绀哄眰涓殑HTML閲屽垎绂诲紑鏉ャ�傝�孞SP鐨勬儏鍐垫槸Java鍜孒TML鍙互缁勫悎鎴愪竴涓墿灞曞悕涓�.jsp鐨勬枃浠躲�侸SP渚ч噸浜庤鍥撅紝Servlet涓昏鐢ㄤ簬鎺у埗閫昏緫銆� 18銆丮VC鐨勫悇涓儴鍒嗛兘鏈夐偅浜涙妧鏈潵瀹炵幇?濡備綍瀹炵幇?绛�:MVC鏄疢odel锛峍iew锛岰ontroller鐨勭畝鍐欍�侻odel浠h〃鐨勬槸搴旂敤鐨勪笟鍔¢�昏緫锛堥�氳繃JavaBean锛孍JB缁勪欢瀹炵幇锛夛紝View鏄簲鐢ㄧ殑琛ㄧず闈紙鐢盝SP椤甸潰浜х敓锛夛紝Controller鏄彁渚涘簲鐢ㄧ殑澶勭悊杩囩▼鎺у埗锛堜竴鑸槸涓�涓猄ervlet锛夛紝閫氳繃杩欑璁捐妯″瀷鎶婂簲鐢ㄩ�昏緫锛屽鐞嗚繃绋嬪拰鏄剧ず閫昏緫鍒嗘垚涓嶅悓鐨勭粍浠跺疄鐜般�傝繖浜涚粍浠跺彲浠ヨ繘琛屼氦浜掑拰閲嶇敤銆� 19銆佹垜浠湪web搴旂敤寮�鍙戣繃绋嬩腑缁忓父閬囧埌杈撳嚭鏌愮缂栫爜鐨勫瓧绗︼紝濡俰so8859-1绛夛紝濡備綍杈撳嚭涓�涓煇绉嶇紪鐮佺殑瀛楃涓诧紵 Public String translate(String str) {聽 String tempStr ="";聽 try {聽 聽 tempStr = newString(str.getBytes("ISO-8859-1"), "GBK");聽 聽 tempStr =tempStr.trim();聽 }聽 catch (Exception e) {聽 聽 System.err.println(e.getMessage());聽 }聽 return tempStr; }鐜板湪杈撳叆n涓暟瀛楋紝浠ラ�楀彿锛屽垎寮�锛涚劧鍚庡彲閫夋嫨鍗囨垨鑰呴檷搴忔帓搴忥紱鎸夋彁浜ら敭灏卞湪鍙︿竴椤甸潰鏄剧ず鎸変粈涔堟帓搴忥紝缁撴灉涓猴紝鎻愪緵reset浜�.鏁版嵁搴撻儴鍒�1銆佺敤涓ょ鏂瑰紡鏍规嵁閮ㄩ棬鍙蜂粠楂樺埌浣庯紝宸ヨ祫浠庝綆鍒伴珮鍒楀嚭姣忎釜鍛樺伐鐨勪俊鎭�俥mployee:聽 聽 eid,ename,salary,deptid; select * from employeeorder by deptid desc,salary聽 2銆佸垪鍑哄悇涓儴闂ㄤ腑宸ヨ祫楂樹簬鏈儴闂ㄧ殑骞冲潎宸ヨ祫鐨勫憳宸ユ暟鍜岄儴闂ㄥ彿锛屽苟鎸夐儴闂ㄥ彿鎺掑簭鍒涘缓琛細聽 聽 聽 mysql> create table employee921(id int primary key auto_increment,name varchar(50),salary bigint,deptid int); 鎻掑叆瀹為獙鏁版嵁锛歮ysql> insert into employee921values(null,'zs',1000,1),(null,'ls',1100,1),(null,'ww',1100,1),(null,'zl',900,1) ,(null,'zl',1000,2), (null,'zl',900,2),(null,'zl',1000,2) , (null,'zl',1100,2); 缂栧啓sql璇彞锛� 锛堬級select avg(salary) from employee921 group by deptid;锛堬級mysql> selectemployee921.id,employee921.name,employee921.salary,employee921.deptid tid from聽 employee921where salary > (select avg(salary) from employee921 where聽 deptid = tid);聽 鏁堢巼浣庣殑涓�涓鍙ワ紝浠呬緵瀛︿範鍙傝�冧娇鐢紙鍦╣roup by涔嬪悗涓嶈兘浣跨敤where锛屽彧鑳戒娇鐢╤aving锛屽湪group by涔嬪墠鍙互浣跨敤where锛屽嵆琛ㄧず瀵硅繃婊ゅ悗鐨勭粨鏋滃垎缁勶級锛歮ysql> selectemployee921.id,employee921.name,employee921.salary,employee921.deptid tid from聽 employee921where salary > (select avg(salary) from employee921 group by deptid havingdeptid = tid);锛堬級select count(*) ,tid聽 聽 聽 from (聽 聽 聽 聽 聽 聽 聽 selectemployee921.id,employee921.name,employee921.salary,employee921.deptid tid聽 聽 聽 聽 聽 聽 聽 from聽 聽 聽 employee921聽 聽 聽 聽 聽 聽 聽 where salary>聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 (selectavg(salary) from employee921 where deptid = tid)聽 聽 聽 ) as t聽 聽 聽 group by tid ; 鍙﹀涓�绉嶆柟寮忥細鍏宠仈鏌ヨselect a.ename,a.salary,a.deptid from emp a,聽 聽 (selectdeptd,avg(salary) avgsal from emp group by deptid ) b where a.deptid=b.deptidand a.salary>b.avgsal;3銆佸瓨鍌ㄨ繃绋嬩笌瑙﹀彂鍣ㄥ繀椤昏锛岀粡甯歌闈㈣瘯鍒�?create procedure insert_Student (_name varchar(50),_age int ,out_id int)begin聽 聽 聽 insert into studentvalue(null,_name,_age);聽 聽 聽 select max(stuId)into _id from student;end; call insert_Student('wfz',23,@id);select @id; mysql> create trigger update_Student BEFORE update on studentFOR EACH ROW-> select * from student;瑙﹀彂鍣ㄤ笉鍏佽杩斿洖缁撴灉 create trigger update_StudentBEFORE update on student FOR EACH ROW insert into聽 student value(null,'zxx',28);mysql鐨勮Е鍙戝櫒鐩墠涓嶈兘瀵瑰綋鍓嶈〃杩涜鎿嶄綔 create trigger update_StudentBEFORE update on student FOR EACH ROW delete from articles聽 where id=8;杩欎釜渚嬪瓙涓嶆槸寰堝ソ锛屾渶濂芥槸鐢ㄥ垹闄や竴涓敤鎴锋椂锛岄『甯﹀垹闄よ鐢ㄦ埛鐨勬墍鏈夊笘瀛愯繖閲岃娉ㄦ剰浣跨敤OLD.id 瑙﹀彂鍣ㄧ敤澶勮繕鏄緢澶氱殑锛屾瘮濡傛牎鍐呯綉銆佸紑蹇冪綉銆丗acebook锛屼綘鍙戜竴涓棩蹇楋紝鑷姩閫氱煡濂藉弸锛屽叾瀹炲氨鏄湪澧炲姞鏃ュ織鏃跺仛涓�涓悗瑙﹀彂锛屽啀鍚戦�氱煡琛ㄤ腑鍐欏叆鏉$洰銆傚洜涓鸿Е鍙戝櫒鏁堢巼楂樸�傝�孶CH娌℃湁鐢ㄨЕ鍙戝櫒锛屾晥鐜囧拰鏁版嵁澶勭悊鑳藉姏閮藉緢浣庛�傚瓨鍌ㄨ繃绋嬬殑瀹為獙姝ラ锛歮ysql> delimiter |mysql> create procedure insertArticle_Procedure (pTitle varchar(50),pBid int,out pId int)聽 聽 -> begin聽 聽 -> insert into article1value(null,pTitle,pBid);聽 聽 -> select max(id) into pId fromarticle1;聽 聽 -> end;聽 聽 -> |Query OK, 0 rows affected (0.05sec) mysql> callinsertArticle_Procedure('浼犳櫤鎾',1,@pid);聽 聽 -> |Query OK, 0 rows affected (0.00sec) mysql> delimiter ;mysql> select @pid;+------+| @pid |+------+| 3聽 聽 |+------+1 row in set (0.00 sec) mysql> select * fromarticle1;+----+--------------+------+| id | title聽 聽 聽 聽 | bid |+----+--------------+------+| 1聽 | test聽 聽 聽 聽 | 1聽 聽 || 2聽 | chuanzhiboke | 1聽 聽 || 3聽 | 浼犳櫤鎾聽 聽 | 1聽 聽 |+----+--------------+------+3 rows in set (0.00 sec) 瑙﹀彂鍣ㄧ殑瀹為獙姝ラ锛歝reate table board1(id intprimary key auto_increment,name varchar(50),articleCount int); create table article1(id intprimary key auto_increment,title varchar(50),bid int referencesboard1(id)); delimiter | create triggerinsertArticle_Trigger after insert on article1 for each row begin聽 聽 -> update board1 setarticleCount=articleCount+1 where id= NEW.bid;聽 聽 -> end;聽 聽 -> | delimiter ; insert into board1 value(null,'test',0); insert into article1value(null,'test',1);杩樻湁锛屾瘡鎻掑叆涓�涓笘瀛愶紝閮藉笇鏈涘皢鐗堥潰琛ㄤ腑鐨勬渶鍚庡彂甯栨椂闂达紝甯栧瓙鎬绘暟瀛楁杩涜鍚屾鏇存柊锛岀敤瑙﹀彂鍣ㄥ仛鏁堢巼灏卞緢楂樸�備笅娆¤璁捐杩欐牱涓�涓渚嬶紝鍐欒Е鍙戝櫒鏃讹紝瀵逛簬鏈�鍚庡彂甯栨椂闂村彲鑳介渶瑕佺敤declare鏂瑰紡澹版槑涓�涓彉閲忥紝鎴栬�呮槸鐢∟EW.posttime鏉ョ敓鎴愩�� 4銆佹暟鎹簱涓夎寖寮忔槸浠�涔�?绗竴鑼冨紡锛�1NF锛夛細瀛楁鍏锋湁鍘熷瓙鎬�,涓嶅彲鍐嶅垎銆傛墍鏈夊叧绯诲瀷鏁版嵁搴撶郴缁熼兘婊¤冻绗竴鑼冨紡锛壜� 聽 聽 鏁版嵁搴撹〃涓殑瀛楁閮芥槸鍗曚竴灞炴�х殑锛屼笉鍙啀鍒嗐�備緥濡傦紝濮撳悕瀛楁锛屽叾涓殑濮撳拰鍚嶅繀椤讳綔涓轰竴涓暣浣擄紝鏃犳硶鍖哄垎鍝儴鍒嗘槸濮擄紝鍝儴鍒嗘槸鍚嶏紝濡傛灉瑕佸尯鍒嗗嚭濮撳拰鍚嶏紝蹇呴』璁捐鎴愪袱涓嫭绔嬬殑瀛楁銆偮� 绗簩鑼冨紡锛�2NF锛夛細绗簩鑼冨紡锛�2NF锛夋槸鍦ㄧ涓�鑼冨紡锛�1NF锛夌殑鍩虹涓婂缓绔嬭捣鏉ョ殑锛屽嵆婊¤冻绗簩鑼冨紡锛�2NF锛夊繀椤诲厛婊¤冻绗竴鑼冨紡锛�1NF锛夈�傝姹傛暟鎹簱琛ㄤ腑鐨勬瘡涓疄渚嬫垨琛屽繀椤诲彲浠ヨ鎯熶竴鍦板尯鍒嗐�傞�氬父闇�瑕佷负琛ㄥ姞涓婁竴涓垪锛屼互瀛樺偍鍚勪釜瀹炰緥鐨勬儫涓�鏍囪瘑銆傝繖涓儫涓�灞炴�у垪琚О涓轰富鍏抽敭瀛楁垨涓婚敭銆� 绗簩鑼冨紡锛�2NF锛夎姹傚疄浣撶殑灞炴�у畬鍏ㄤ緷璧栦簬涓诲叧閿瓧銆傛墍璋撳畬鍏ㄤ緷璧栨槸鎸囦笉鑳藉瓨鍦ㄤ粎渚濊禆涓诲叧閿瓧涓�閮ㄥ垎鐨勫睘鎬э紝濡傛灉瀛樺湪锛岄偅涔堣繖涓睘鎬у拰涓诲叧閿瓧鐨勮繖涓�閮ㄥ垎搴旇鍒嗙鍑烘潵褰㈡垚涓�涓柊鐨勫疄浣擄紝鏂板疄浣撲笌鍘熷疄浣撲箣闂存槸涓�瀵瑰鐨勫叧绯汇�備负瀹炵幇鍖哄垎閫氬父闇�瑕佷负琛ㄥ姞涓婁竴涓垪锛屼互瀛樺偍鍚勪釜瀹炰緥鐨勬儫涓�鏍囪瘑銆傜畝鑰岃█涔嬶紝绗簩鑼冨紡灏辨槸闈炰富灞炴�ч潪閮ㄥ垎渚濊禆浜庝富鍏抽敭瀛椼�偮� 绗笁鑼冨紡鐨勮姹傚涓嬶細婊¤冻绗笁鑼冨紡锛�3NF锛夊繀椤诲厛婊¤冻绗簩鑼冨紡锛�2NF锛夈�傜畝鑰岃█涔嬶紝绗笁鑼冨紡锛�3NF锛夎姹備竴涓暟鎹簱琛ㄤ腑涓嶅寘鍚凡鍦ㄥ叾瀹冭〃涓凡鍖呭惈鐨勯潪涓诲叧閿瓧淇℃伅銆傛墍浠ョ涓夎寖寮忓叿鏈夊涓嬬壒寰侊細聽 聽 聽 聽 1锛屾瘡涓�鍒楀彧鏈変竴涓�悸� 聽 聽 聽 2锛屾瘡涓�琛岄兘鑳藉尯鍒嗐�偮� 聽 聽 聽 3锛屾瘡涓�涓〃閮戒笉鍖呭惈鍏朵粬琛ㄥ凡缁忓寘鍚殑闈炰富鍏抽敭瀛椾俊鎭�備緥濡傦紝甯栧瓙琛ㄤ腑鍙兘鍑虹幇鍙戝笘浜虹殑id锛岃�屼笉鑳藉嚭鐜板彂甯栦汉鐨刬d锛岃繕鍚屾椂鍑虹幇鍙戝笘浜哄鍚嶏紝鍚﹀垯锛屽彧瑕佸嚭鐜板悓涓�鍙戝笘浜篿d鐨勬墍鏈夎褰曪紝瀹冧滑涓殑濮撳悕閮ㄥ垎閮藉繀椤讳弗鏍间繚鎸佷竴鑷达紝杩欏氨鏄暟鎹啑浣欍�� 5銆佽鍑轰竴浜涙暟鎹簱浼樺寲鏂归潰鐨勭粡楠�?鐢≒reparedStatement涓�鑸潵璇存瘮Statement鎬ц兘楂橈細涓�涓猻ql鍙戠粰鏈嶅姟鍣ㄥ幓鎵ц锛屾秹鍙婃楠わ細璇硶妫�鏌ャ�佽涔夊垎鏋愶紝缂栬瘧锛岀紦瀛樷�渋nert into user values(1,1,1)鈥�-脿浜岃繘鍒垛�渋nert into user values(2,2,2)鈥�-脿浜岃繘鍒垛�渋nert into user values(?,?,?)鈥�-脿浜岃繘鍒舵湁澶栭敭绾︽潫浼氬奖鍝嶆彃鍏ュ拰鍒犻櫎鎬ц兘锛屽鏋滅▼搴忚兘澶熶繚璇佹暟鎹殑瀹屾暣鎬э紝閭e湪璁捐鏁版嵁搴撴椂灏卞幓鎺夊閿�傦紙姣斿柣锛氬氨濂芥瘮鍏嶆浜у搧锛屽氨鏄负浜嗘彁楂樻晥鐜囷紝鍏呭垎鐩镐俊浜у搧鐨勫埗閫犲晢锛夛紙瀵逛簬hibernate鏉ヨ锛屽氨搴旇鏈変竴涓彉鍖栵細empleyee->Deptment瀵硅薄锛岀幇鍦ㄨ璁℃椂灏辨垚浜唀mployee脿deptid锛� 鐪媘ysql甯姪鏂囨。瀛愭煡璇㈢珷鑺傜殑鏈�鍚庨儴鍒嗭紝渚嬪锛屾牴鎹壂鎻忕殑鍘熺悊锛屼笅闈㈢殑瀛愭煡璇㈣鍙ヨ姣旂浜屾潯鍏宠仈鏌ヨ鐨勬晥鐜囬珮锛�1.聽 select e.name,e.salarywhere e.managerid=(select id from employee where name='zxx'); 2.聽 select e.name,e.salary,m.name,m.salary from employees e,employees m where e.managerid = m.id andm.name='zxx'; 琛ㄤ腑鍏佽閫傚綋鍐椾綑锛岃濡傦紝涓婚甯栫殑鍥炲鏁伴噺鍜屾渶鍚庡洖澶嶆椂闂寸瓑灏嗗鍚嶅拰瀵嗙爜鍗曠嫭浠庣敤鎴疯〃涓嫭绔嬪嚭鏉ャ�傝繖鍙互鏄潪甯稿ソ鐨勪竴瀵逛竴鐨勬渚嬪摕锛� sql璇彞鍏ㄩ儴澶у啓锛岀壒鍒槸鍒楀悕鍜岃〃鍚嶉兘澶у啓銆傜壒鍒槸sql鍛戒护鐨勭紦瀛樺姛鑳斤紝鏇村姞闇�瑕佺粺涓�澶у皬鍐欙紝sql璇彞脿鍙戠粰oracle鏈嶅姟鍣犺娉曟鏌ュ拰缂栬瘧鎴愪负鍐呴儴鎸囦护脿缂撳瓨鍜屾墽琛屾寚浠ゃ�傛牴鎹紦瀛樼殑鐗圭偣锛屼笉瑕佹嫾鍑戞潯浠讹紝鑰屾槸鐢�?鍜孭reparedStatment 杩樻湁绱㈠紩瀵规煡璇㈡�ц兘鐨勬敼杩涗篃鏄�煎緱鍏虫敞鐨勩�� 澶囨敞锛氫笅闈㈡槸鍏充簬鎬ц兘鐨勮璁轰妇渚� 4鑸彮 3涓煄甯� m*n select * from flight,city where flight.startcityid=city.cityidand city.name='beijing'; m + n聽 select * from flight where startcityid = (select cityid fromcity where cityname='beijing'); select flight.id,'beijing',flight.flightTime from flight wherestartcityid = (select cityid from city where cityname='beijing')6銆乽nion鍜寀nion all鏈変粈涔堜笉鍚�?鍋囪鎴戜滑鏈変竴涓〃Student锛屽寘鎷互涓嬪瓧娈典笌鏁版嵁锛歞rop table student;create table student(id int primary key,name nvarchar2(50) not null,score number not null);insert into student values(1,'Aaron',78);insert into student values(2,'Bill',76);insert into student values(3,'Cindy',89);insert into student values(4,'Damon',90);insert into student values(5,'Ella',73);insert into student values(6,'Frado',61);insert into student values(7,'Gill',99);insert into student values(8,'Hellen',56);insert into student values(9,'Ivan',93);insert into student values(10,'Jay',90);commit;Union鍜孶nion All鐨勫尯鍒�俿elect *from studentwhere id < 4unionselect *from studentwhere id > 2 and id < 6缁撴灉灏嗘槸1聽 聽 Aaron聽 聽 782聽 聽 Bill聽 聽 763聽 聽 Cindy聽 聽 894聽 聽 Damon聽 聽 905聽 聽 Ella聽 聽 73濡傛灉鎹㈡垚Union All杩炴帴涓や釜缁撴灉闆嗭紝鍒欒繑鍥炵粨鏋滄槸锛�1聽 聽 Aaron聽 聽 782聽 聽 Bill聽 聽 763聽 聽 Cindy聽 聽 893聽 聽 Cindy聽 聽 894聽 聽 Damon聽 聽 905聽 聽 Ella聽 聽 73鍙互鐪嬪埌锛孶nion鍜孶nion All鐨勫尯鍒箣涓�鍦ㄤ簬瀵归噸澶嶇粨鏋滅殑澶勭悊銆� UNION鍦ㄨ繘琛岃〃閾炬帴鍚庝細绛涢�夋帀閲嶅鐨勮褰曪紝鎵�浠ュ湪琛ㄩ摼鎺ュ悗浼氬鎵�浜х敓鐨勭粨鏋滈泦杩涜鎺掑簭杩愮畻锛屽垹闄ら噸澶嶇殑璁板綍鍐嶈繑鍥炵粨鏋溿�傚疄闄呭ぇ閮ㄥ垎搴旂敤涓槸涓嶄細浜х敓閲嶅鐨勮褰曪紝鏈�甯歌鐨勬槸杩囩▼琛ㄤ笌鍘嗗彶琛║NION銆傚锛歴elect * from gc_dfysunionselect * from ls_jg_dfys銆�銆�杩欎釜SQL鍦ㄨ繍琛屾椂鍏堝彇鍑轰袱涓〃鐨勭粨鏋滐紝鍐嶇敤鎺掑簭绌洪棿杩涜鎺掑簭鍒犻櫎閲嶅鐨勮褰曪紝鏈�鍚庤繑鍥炵粨鏋滈泦锛屽鏋滆〃鏁版嵁閲忓ぇ鐨勮瘽鍙兘浼氬鑷寸敤纾佺洏杩涜鎺掑簭銆傘��鑰孶NION ALL鍙槸绠�鍗曠殑灏嗕袱涓粨鏋滃悎骞跺悗灏辫繑鍥炪�傝繖鏍凤紝濡傛灉杩斿洖鐨勪袱涓粨鏋滈泦涓湁閲嶅鐨勬暟鎹紝閭d箞杩斿洖鐨勭粨鏋滈泦灏变細鍖呭惈閲嶅鐨勬暟鎹簡銆傘��浠庢晥鐜囦笂璇达紝UNION ALL瑕佹瘮UNION蹇緢澶氾紝鎵�浠ワ紝濡傛灉鍙互纭鍚堝苟鐨勪袱涓粨鏋滈泦涓笉鍖呭惈閲嶅鐨勬暟鎹殑璇濓紝閭d箞灏变娇鐢║NION ALL锛�7.鍒嗛〉璇彞鍙栧嚭sql琛ㄤ腑绗�31鍒�40鐨勮褰曪紙浠ヨ嚜鍔ㄥ闀縄D涓轰富閿級sql server鏂规1锛毬� 聽 selecttop 10 * from t where id not in (select top 30 id from t order by id ) orde byidsql server鏂规2锛毬� 聽 selecttop 10 * from t where id in (select top 40 id from t order by id) order by iddesc mysql鏂规锛歴elect * from t order by idlimit 30,10 oracle鏂规锛歴elect * from (select rownum r,* from t where r<=40) wherer>30 --------------------寰呮暣鐞嗚繘鍘荤殑鍐呭-------------------------------------pageSize=20;pageNo = 5; 1.鍒嗛〉鎶�鏈�1锛堢洿鎺ュ埄鐢╯ql璇彞杩涜鍒嗛〉锛屾晥鐜囨渶楂樺拰鏈�鎺ㄨ崘鐨勶級 mysql:sql = "select * from articles limit " +(pageNo-1)*pageSize + "," + pageSize;oracle: sql = "select * from " +聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "(selectrownum r,* from " +聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "(select* from articles order by postime desc)" +聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "whererownum<= " + pageNo*pageSize +") tmp " +聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "wherer>" + (pageNo-1)*pageSize;娉ㄩ噴锛氱7琛屼繚璇乺ownum鐨勯『搴忔槸纭畾鐨勶紝鍥犱负oracle鐨勭储寮曚細閫犳垚rownum杩斿洖涓嶅悓鐨勫�肩畝娲嬫彁绀猴細娌℃湁order by鏃讹紝rownum鎸夐『搴忚緭鍑猴紝涓�鏃︽湁浜唎rder by锛宺ownum涓嶆寜椤哄簭杈撳嚭浜嗭紝杩欒鏄巖ownum鏄帓搴忓墠鐨勭紪鍙枫�傚鏋滃order by浠庡彞涓殑瀛楁寤虹珛浜嗙储寮曪紝閭d箞锛宺ownum涔熸槸鎸夐『搴忚緭鍑虹殑锛屽洜涓鸿繖鏃跺�欑敓鎴愬師濮嬬殑鏌ヨ缁撴灉闆嗘椂浼氬弬鐓х储寮曡〃鐨勯『搴忔潵鏋勫缓銆� sqlserver:sql = "select top 10 * from id not id(select top" + (pageNo-1)*pageSize + "id from articles)" DataSource ds = new InitialContext().lookup(jndiurl);Connection cn = ds.getConnection();//"select * from user where id=?"聽 --->binary directivePreparedStatement pstmt = cn.prepareSatement(sql);ResultSet rs = pstmt.executeQuery()while(rs.next()){聽 聽 聽 out.println(rs.getString(1));} 2.涓嶅彲婊氬姩鐨勬父鏍噋ageSize=20;pageNo = 5;cn = nullstmt = null;rs = null;try{sqlserver:sql = "select * from articles"; DataSource ds = new InitialContext().lookup(jndiurl);Connection cn = ds.getConnection();//"select * from user where id=?"聽 --->binary directivePreparedStatement pstmt = cn.prepareSatement(sql);ResultSet rs = pstmt.executeQuery()for(int j=0;j<(pageNo-1)*pageSize;j++){聽 聽 聽 rs.next();} int i=0; while(rs.next() && i<10){聽 聽 聽 i++;聽 聽 聽 out.println(rs.getString(1));}}cacth(){}finnaly{聽 聽 聽 if(rs!=null)try{rs.close();}catch(Exceptione){}聽 聽 聽 if(stm.........聽 聽 聽 if(cn............} 3.鍙粴鍔ㄧ殑娓告爣pageSize=20;pageNo = 5;cn = nullstmt = null;rs = null;try{sqlserver:sql = "select * from articles"; DataSource ds = new InitialContext().lookup(jndiurl);Connection cn = ds.getConnection();//"select * from user where id=?"聽 --->binary directivePreparedStatement pstmt = cn.prepareSatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,...);//鏍规嵁涓婇潰杩欒浠g爜鐨勫紓甯窼QLFeatureNotSupportedException锛屽氨鍙垽鏂┍鍔ㄦ槸鍚︽敮鎸佸彲婊氬姩娓告爣 ResultSet rs = pstmt.executeQuery()rs.absolute((pageNo-1)*pageSize)int i=0;while(rs.next() && i<10){聽 聽 聽 i++;聽 聽 聽 out.println(rs.getString(1));}}cacth(){}finnaly{聽 聽 聽 if(rs!=null)try{rs.close();}catch(Exceptione){}聽 聽 聽 if(stm.........聽 聽 聽 if(cn............}8.鐢ㄤ竴鏉QL璇彞鏌ヨ鍑烘瘡闂ㄨ閮藉ぇ浜�80鍒嗙殑瀛︾敓濮撳悕 name聽 kecheng聽 fenshu 寮犱笁聽 聽 璇枃聽 聽 聽 81寮犱笁聽 聽 鏁板聽 聽 聽 75鏉庡洓聽 聽 璇枃聽 聽 聽 76鏉庡洓聽 聽 鏁板聽 聽 聽 90鐜嬩簲聽 聽 璇枃聽 聽 聽 81鐜嬩簲聽 聽 鏁板聽 聽 聽 100鐜嬩簲聽 聽 鑻辫聽 聽 聽 90鍑嗗鏁版嵁鐨剆ql浠g爜锛歝reate table score(id int primary key auto_increment,namevarchar(20),subject varchar(20),score int);insert into score values(null,'寮犱笁','璇枃',81),(null,'寮犱笁','鏁板',75),(null,'鏉庡洓','璇枃',76),(null,'鏉庡洓','鏁板',90),(null,'鐜嬩簲','璇枃',81),(null,'鐜嬩簲','鏁板',100),(null,'鐜嬩簲 ','鑻辫',90); 鎻愮ず锛氬綋鐧炬�濅笉寰楀叾瑙f椂锛岃鐞嗘兂鎬濈淮锛屾妸灏忓彉鎴愬ぇ鍋氾紝鎶婂ぇ鍙樻垚灏忓仛锛� 绛旀锛欰: select distinct name from score聽 where聽 name not in (selectdistinct name from score where score<=80) B:select distince name t1 from score where 80< all (selectscore from score where name=t1); 9.鎵�鏈夐儴闂ㄤ箣闂寸殑姣旇禌缁勫悎涓�涓彨department鐨勮〃锛岄噷闈㈠彧鏈変竴涓瓧娈祅ame,涓�鍏辨湁4鏉$邯褰曪紝鍒嗗埆鏄痑,b,c,d,瀵瑰簲鍥涗釜鐞冨锛岀幇鍦ㄥ洓涓悆瀵硅繘琛屾瘮璧涳紝鐢ㄤ竴鏉ql璇彞鏄剧ず鎵�鏈夊彲鑳界殑姣旇禌缁勫悎.绛旓細select a.name,b.name from team a, team b where a.name < b.name 10.姣忎釜鏈堜唤鐨勫彂鐢熼閮芥瘮101绉戠洰澶氱殑绉戠洰璇风敤SQL璇彞瀹炵幇锛氫粠TestDB鏁版嵁琛ㄤ腑鏌ヨ鍑烘墍鏈夋湀浠界殑鍙戠敓棰濋兘姣�101绉戠洰鐩稿簲鏈堜唤鐨勫彂鐢熼楂樼殑绉戠洰銆傝娉ㄦ剰锛歍estDB涓湁寰堝绉戠洰锛岄兘鏈�1锛�12鏈堜唤鐨勫彂鐢熼銆侫ccID锛氱鐩唬鐮侊紝Occmonth锛氬彂鐢熼鏈堜唤锛孌ebitOccur锛氬彂鐢熼銆傛暟鎹簱鍚嶏細JcyAudit锛屾暟鎹泦锛歋elect * from TestDB鍑嗗鏁版嵁鐨剆ql浠g爜锛歞rop table if exists TestDB;create table TestDB(id int primary key auto_increment,AccIDvarchar(20), Occmonth date, DebitOccur bigint);insert into TestDB values(null,'101','1988-1-1',100),(null,'101','1988-2-1',110),(null,'101','1988-3-1',120),(null,'101','1988-4-1',100),(null,'101','1988-5-1',100),(null,'101','1988-6-1',100),(null,'101','1988-7-1',100),(null,'101','1988-8-1',100);--澶嶅埗涓婇潰鐨勬暟鎹紝鏁呮剰鎶婄涓�涓湀浠界殑鍙戠敓棰濇暟瀛楁敼灏忎竴鐐筰nsert into TestDB values(null,'102','1988-1-1',90),(null,'102','1988-2-1',110),(null,'102','1988-3-1',120),(null,'102','1988-4-1',100),(null,'102','1988-5-1',100),(null,'102','1988-6-1',100),(null,'102','1988-7-1',100),(null,'102','1988-8-1',100);--澶嶅埗鏈�涓婇潰鐨勬暟鎹紝鏁呮剰鎶婃墍鏈夊彂鐢熼鏁板瓧鏀瑰ぇ涓�鐐筰nsert into TestDB values(null,'103','1988-1-1',150),(null,'103','1988-2-1',160),(null,'103','1988-3-1',180),(null,'103','1988-4-1',120),(null,'103','1988-5-1',120),(null,'103','1988-6-1',120),(null,'103','1988-7-1',120),(null,'103','1988-8-1',120);--澶嶅埗鏈�涓婇潰鐨勬暟鎹紝鏁呮剰鎶婃墍鏈夊彂鐢熼鏁板瓧鏀瑰ぇ涓�鐐筰nsert into TestDB values(null,'104','1988-1-1',130),(null,'104','1988-2-1',130),(null,'104','1988-3-1',140),(null,'104','1988-4-1',150),(null,'104','1988-5-1',160),(null,'104','1988-6-1',170),(null,'104','1988-7-1',180),(null,'104','1988-8-1',140);--澶嶅埗鏈�涓婇潰鐨勬暟鎹紝鏁呮剰鎶婄浜屼釜鏈堜唤鐨勫彂鐢熼鏁板瓧鏀瑰皬涓�鐐筰nsert into TestDB values(null,'105','1988-1-1',100),(null,'105','1988-2-1',80),(null,'105','1988-3-1',120),(null,'105','1988-4-1',100),(null,'105','1988-5-1',100),(null,'105','1988-6-1',100),(null,'105','1988-7-1',100),(null,'105','1988-8-1',100);绛旀锛歴elect distinct AccID from TestDBwhere AccID not in聽 聽 聽 (selectTestDB.AccIDfrom TestDB,聽 聽 聽 聽 聽 聽 聽 (select * from TestDB where AccID='101') asdb101聽 聽 聽 whereTestDB.Occmonth=db101.Occmonth and TestDB.DebitOccur<=db101.DebitOccur聽 聽 聽 ); 11.缁熻姣忓勾姣忔湀鐨勪俊鎭痽ear聽 monthamount1991聽 1聽 聽 1.11991聽 2聽 聽 1.21991聽 3聽 聽 1.31991聽 4聽 聽 1.41992聽 1聽 聽 2.11992聽 2聽 聽 2.21992聽 3聽 聽 2.31992聽 4聽 聽 2.4鏌ユ垚杩欐牱涓�涓粨鏋測ear m1聽 m2聽 m3聽 m41991 1.1 1.2 1.3 1.41992 2.1 2.2 2.3 2.4 鎻愮ず锛氳繖涓笌宸ヨ祫鏉¢潪甯哥被浼硷紝涓庡鐢熺殑绉戠洰鎴愮哗涔熷緢鐩镐技銆� 鍑嗗sql璇彞锛歞rop table if existssales;create table sales(idint auto_increment primary key,year varchar(10), month varchar(10), amountfloat(2,1));insert into salesvalues(null,'1991','1',1.1),(null,'1991','2',1.2),(null,'1991','3',1.3),(null,'1991','4',1.4),(null,'1992','1',2.1),(null,'1992','2',2.2),(null,'1992','3',2.3),(null,'1992','4',2.4);绛旀涓�銆乻elect sales.year ,(select t.amount fromsales t where t.month='1' and t.year= sales.year) '1',(select t.amount fromsales t where t.month='1' and t.year= sales.year) '2',(select t.amount fromsales t where t.month='1' and t.year= sales.year) '3',(select t.amount fromsales t where t.month='1' and t.year= sales.year) as '4'from sales聽 group by year; 12.鏄剧ず鏂囩珷鏍囬锛屽彂甯栦汉銆佹渶鍚庡洖澶嶆椂闂磋〃锛歩d,title,postuser,postdate,parentid鍑嗗sql璇彞锛歞rop table if exists articles;create table articles(id int auto_increment primary key,titlevarchar(50), postuser varchar(10), postdate datetime,parentid int referencesarticles(id));insert into articles values(null,'绗竴鏉�','寮犱笁','1998-10-10 12:32:32',null),(null,'绗簩鏉�','寮犱笁','1998-10-10 12:34:32',null),(null,'绗竴鏉″洖澶�1','鏉庡洓','1998-10-10 12:35:32',1),(null,'绗簩鏉″洖澶�1','鏉庡洓','1998-10-10 12:36:32',2),(null,'绗竴鏉″洖澶�2','鐜嬩簲','1998-10-10 12:37:32',1),(null,'绗竴鏉″洖澶�3','鏉庡洓','1998-10-10 12:38:32',1),(null,'绗簩鏉″洖澶�2','鏉庡洓','1998-10-10 12:39:32',2),(null,'绗竴鏉″洖澶�4','鐜嬩簲','1998-10-10 12:39:40',1); 绛旀锛歴elect a.title,a.postuser,聽 聽 聽 (selectmax(postdate) from articles where parentid=a.id) replyfrom articles a where a.parentid is null; 娉ㄩ噴锛氬瓙鏌ヨ鍙互鐢ㄥ湪閫夋嫨鍒椾腑锛屼篃鍙敤浜巜here鐨勬瘮杈冩潯浠朵腑锛岃繕鍙互鐢ㄤ簬from浠庡彞涓��13.鍒犻櫎闄や簡id鍙蜂笉鍚�,鍏朵粬閮界浉鍚岀殑瀛︾敓鍐椾綑淇℃伅2.瀛︾敓琛ㄥ涓�:id鍙仿� 瀛﹀彿聽 濮撳悕璇剧▼缂栧彿璇剧▼鍚嶇О鍒嗘暟1聽 聽 聽 聽 2005001聽 寮犱笁 0001聽 聽 鏁板聽 聽 692聽 聽 聽 聽 2005002聽 鏉庡洓 0001聽 聽 鏁板聽 聽 893聽 聽 聽 聽 2005001聽 寮犱笁 0001聽 聽 鏁板聽 聽 69A: delete from tablename where id鍙� not in(select min(id鍙�) from tablename group by瀛﹀彿,濮撳悕,璇剧▼缂栧彿,璇剧▼鍚嶇О,鍒嗘暟)瀹為獙锛歝reate table student2(id int auto_increment primary key,codevarchar(20),name varchar(20));insert into student2 values(null,'2005001','寮犱笁'),(null,'2005002','鏉庡洓'),(null,'2005001','寮犱笁'); //濡備笅璇彞锛宮ysql鎶ュ憡閿欒锛屽彲鑳藉垹闄や緷璧栧悗闈㈢粺璁¤鍙ワ紝鑰屽垹闄ゅ張瀵艰嚧缁熻璇彞缁撴灉涓嶄竴鑷淬�� delete from student2 where id not in(select min(id) fromstudent2 group by name);//浣嗘槸锛屽涓嬭鍙ユ病鏈夐棶棰橈細select *聽 from student2where id not in(select min(id) from student2 group by name);//浜庢槸锛屾垜鎯冲厛鎶婂垎缁勭殑缁撴灉鍋氭垚铏氳〃锛岀劧鍚庝粠铏氳〃涓�夊嚭缁撴灉锛屾渶鍚庡啀灏嗙粨鏋滀綔涓哄垹闄ょ殑鏉′欢鏁版嵁銆俤elete from student2 where id not in(select mid from (select min(id) mid from student2 group by name) as t);鎴栬�咃細delete from student2 where id not in(select min(id) from (select* from student2) as t group by t.name);14.鑸┖缃戠殑鍑犱釜鑸彮鏌ヨ棰橈細琛ㄧ粨鏋勫涓嬶細flight{flightID,StartCityID ,endCityID,StartTime}city{cityID, CityName)瀹為獙鐜锛歝reate table city(cityID int auto_increment primary key,cityNamevarchar(20));create table flight (flightID int auto_increment primary key,聽 聽 聽 StartCityID intreferences city(cityID),聽 聽 聽 endCityID聽 int references city(cityID),聽 聽 聽 StartTimetimestamp);//鑸彮鏈潵搴旇娌℃湁鏃ユ湡閮ㄥ垎鎵嶅ソ锛屼絾鏄笅闈㈢殑棰樼洰褰撲腑娑夊強鍒颁簡鏃ユ湡insert into city values(null,'鍖椾含'),(null,'涓婃捣'),(null,'骞垮窞');insert into flight values聽 聽 聽 (null,1,2,'9:37:23'),(null,1,3,'9:37:23'),(null,1,2,'10:37:23'),(null,2,3,'10:37:23');聽 1銆佹煡璇㈣捣椋炲煄甯傛槸鍖椾含鐨勬墍鏈夎埅鐝紝鎸夊埌杈惧煄甯傜殑鍚嶅瓧鎺掑簭聽 鍙備笌杩愮畻鐨勫垪鏄垜璧风爜鑳藉鏄剧ず鍑烘潵鐨勯偅浜涘垪锛屼絾鏈�缁堟垜涓嶄竴瀹氭妸瀹冧滑鏄剧ず鍑烘潵銆傚悇涓〃缁勫悎鍑烘潵鐨勪腑闂寸粨鏋滃瓧娈典腑蹇呴』鍖呭惈鎵�鏈夎繍绠楃殑瀛楁銆偮� select聽 * from flight f,city c聽 聽 聽 where f.endcityid =c.cityid and startcityid =聽 聽 聽 (select c1.cityidfrom city c1 where c1.cityname = "鍖椾含")聽 聽 聽 order by c.citynameasc; mysql> select flight.flightid,'鍖椾含' startcity, e.cityname from flight,city e where flight.endcityid=e.cityid and flight.startcityid=(selectcityid from city where cityname='鍖椾含'); mysql> select flight.flightid,s.cityname,e.cityname fromflight,city s,city e where flight.startcityid=s.cityid and s.cityname='鍖椾含' andflight.endCityId=e.cityID order by e.cityName desc;聽 2銆佹煡璇㈠寳浜埌涓婃捣鐨勬墍鏈夎埅鐝邯褰曪紙璧烽鍩庡競锛屽埌杈惧煄甯傦紝璧烽鏃堕棿锛岃埅鐝彿锛塻elect c1.CityName,c2.CityName,f.StartTime,f.flightIDfrom city c1,city c2,flight fwhere f.StartCityID=c1.cityIDand f.endCityID=c2.cityIDand c1.cityName='鍖椾含'and c2.cityName='涓婃捣'3銆佹煡璇㈠叿浣撴煇涓�澶╋紙2005-5-8锛夌殑鍖椾含鍒颁笂娴风殑鐨勮埅鐝鏁皊elect count(*) from(select c1.CityName,c2.CityName,f.StartTime,f.flightIDfrom city c1,city c2,flight fwhere f.StartCityID=c1.cityIDand f.endCityID=c2.cityIDand c1.cityName='鍖椾含'and c2.cityName='涓婃捣'and 鏌ュ府鍔╄幏寰楃殑鏌愪釜鏃ユ湡澶勭悊鍑芥暟(startTime) like '2005-5-8%' mysql涓彁鍙栨棩鏈熼儴鍒嗚繘琛屾瘮杈冪殑绀轰緥浠g爜濡備笅锛歴elect * from flight wheredate_format(starttime,'%Y-%m-%d')='1998-01-02'15.鏌ュ嚭姣旂粡鐞嗚柂姘磋繕楂樼殑鍛樺伐淇℃伅锛欴rop table if not exists employees;create table employees(id int primary key auto_increment,namevarchar(50),salary int,managerid intreferences employees(id));insert into employees values (null,' lhm',10000,null), (null,'zxx',15000,1),(null,'flx',9000,1),(null,'tg',10000,2),(null,'wzg',10000,3); Wzg澶т簬flx,lhm澶т簬zxx 瑙i鎬濊矾锛毬� 聽 鏍规嵁sql璇彞鐨勬煡璇㈢壒鐐癸紝鏄�愯杩涜杩愮畻锛屼笉鍙兘涓よ鍚屾椂鍙備笌杩愮畻銆傛秹鍙婁簡鍛樺伐钖按鍜岀粡鐞嗚柂姘达紝鎵�鏈夛紝涓�琛岃褰曡鍚屾椂鍖呭惈涓や釜钖按锛屾墍鏈夋兂鍒拌鎶婅繖涓〃鑷叧鑱旂粍鍚堜竴涓嬨�偮� 聽 棣栧厛瑕佺粍鍚堝嚭涓�涓寘鍚湁鍚勪釜鍛樺伐鍙婅鍛樺伐鐨勭粡鐞嗕俊鎭殑闀胯褰曪紝璀锛屽乏鍗婇儴鍒嗘槸鍛樺伐锛屽彸鍗婇儴鍒嗘槸缁忕悊銆傝�岃开鍗″皵绉細缁勫悎鍑哄緢澶氬瀮鍦句俊鎭紝鍏堝幓闄よ繖浜涘瀮鍦句俊鎭�� select e.* from employees e,employees m where e.managerid=m.idand e.salary>m.salary;16銆佹眰鍑哄皬浜�45宀佺殑鍚勪釜鑰佸笀鎵�甯︾殑澶т簬12宀佺殑瀛︾敓浜烘暟鏁版嵁搴撲腑鏈�3涓〃 teacher琛紝student琛紝tea_stu鍏崇郴琛ㄣ�倀eacher 琛� teaID name agestudent 琛� stuID name ageteacher_student琛� teaID stuID瑕佹眰鐢ㄤ竴鏉ql鏌ヨ鍑鸿繖鏍风殑缁撴灉1.鏄剧ず鐨勫瓧娈佃鏈夎�佸笀name, age姣忎釜鑰佸笀鎵�甯︾殑瀛︾敓浜烘暟2 鍙垪鍑鸿�佸笀age涓�40浠ヤ笅锛屽鐢焌ge涓�12浠ヤ笂鐨勮褰曢澶囩煡璇嗭細聽 聽 聽 1.sql璇彞鏄姣忎竴鏉¤褰曚緷娆″鐞嗭紝鏉′欢涓虹湡鍒欐墽琛屽姩浣滐紙select,insert,delete,update锛壜� 聽 聽 2.鍙鏄开鍗″皵绉紝灏变細浜х敓鈥滃瀮鍦锯�濅俊鎭紝鎵�浠ワ紝鍙杩崱灏旂Н浜嗭紝鎴戜滑棣栧厛灏辫鎯冲埌娓呴櫎鈥滃瀮鍦锯�濅俊鎭疄楠屽噯澶囷細聽 聽 聽 drop table if exists tea_stu;聽 聽 聽 drop table if exists teacher;聽 聽 聽 drop table if exists student;聽 聽 聽 create table teacher(teaID int primarykey,name varchar(50),age int);聽 聽 聽 create table student(stuID int primarykey,name varchar(50),age int);聽 聽 聽 create table tea_stu(teaID int referencesteacher(teaID),stuID int references student(stuID));insertinto teacher values(1,'zxx',45), (2,'lhm',25) , (3,'wzg',26) , (4,'tg',27);insertinto student values(1,'wy',11), (2,'dh',25) , (3,'ysq',26) , (4,'mxc',27);insertinto tea_stu values(1,1), (1,2), (1,3);insertinto tea_stu values(2,2), (2,3), (2,4); insert into tea_stu values(3,3), (3,4), (3,1);insertinto tea_stu values(4,4), (4,1), (4,2) , (4,3); 缁撴灉锛�2脿3,3脿2,4脿3 瑙i鎬濊矾锛氾紙鐪熷疄闈㈣瘯绛旈鏃讹紝涔熻鍐欏嚭姣忎釜鍒嗘瀽姝ラ锛屽鏋滅焊寮犱笉澶燂紝灏辨壘鍒汉瑕侊級1瑕佷細缁熻鍒嗙粍淇℃伅锛岀粺璁′俊鎭斁鍦ㄤ腑闂磋〃涓細selectteaid,count(*) from tea_stu group by teaid; 2鎺ョ潃鍏跺疄搴旇鏄瓫闄ゆ帀灏忎簬12宀佺殑瀛︾敓锛岀劧鍚庡啀杩涜缁熻锛屼腑闂磋〃蹇呴』涓巗tudent鍏宠仈鎵嶈兘寰楀埌12宀佷互涓嬪鐢熷拰鎶婅瀛︾敓璁板綍浠庝腑闂磋〃涓墧闄わ紝浠g爜鏄細selecttea_stu.teaid,count(*) total from student,tea_stuwherestudent.stuid=tea_stu.stuid and student.age>12 group by tea_stu.teaid 3.鎺ョ潃鎶婁笂闈㈢殑缁撴灉鍋氭垚铏氳〃涓巘eacher杩涜鍏宠仈锛屽苟绛涢櫎澶т簬45鐨勮�佸笀selectteacher.teaid,teacher.name,total from teacher ,(select tea_stu.teaid,count(*)total from student,tea_stu where student.stuid=tea_stu.stuid and student.age>12group by tea_stu.teaid) as tea_stu2where teacher.teaid=tea_stu2.teaidand teacher.age<45;聽 17.姹傚嚭鍙戝笘鏈�澶氱殑浜猴細select authorid,count(*) total from articlesgroup by authoridhaving total=(select max(total2) from(select count(*) total2 from articles group by authorid) as t); select t.authorid,max(t.total) from锛坰elect authorid,count(*) total from articles锛塧s t杩欐潯璇彞涓嶈锛屽洜涓簃ax鍙湁涓�鍒楋紝涓嶈兘涓庡叾浠栧垪娣锋穯銆� select authorid,count(*) total from articlesgroup by authorid having total=max(total)涔熶笉琛屻�� 18銆佷竴涓敤鎴疯〃涓湁涓�涓Н鍒嗗瓧娈碉紝鍋囧鏁版嵁搴撲腑鏈�100澶氫竾涓敤鎴凤紝鑻ヨ鍦ㄦ瘡骞寸涓�澶╁噷鏅ㄥ皢绉垎娓呴浂锛屼綘灏嗚�冭檻浠�涔堬紝浣犲皢鎯充粈涔堝姙娉曡В鍐�?alter table drop column score;alter table add colunm score int;鍙兘浼氬緢蹇紝浣嗘槸闇�瑕佽瘯楠岋紝璇曢獙涓嶈兘鎷跨湡瀹炵殑鐜鏉ユ搷鍒�锛屽苟涓旇娉ㄦ剰锛岃繖鏍风殑鎿嶄綔鏃舵棤娉曞洖婊氱殑锛屽湪鎴戠殑鍗拌薄涓紝鍙湁inert update delete绛塂ML璇彞鎵嶈兘鍥炴粴锛屽浜巆reate table,drop table ,alter table绛塂DL璇彞鏄笉鑳藉洖婊氥�偮� 瑙e喅鏂规涓�锛寀pdate user set score=0;瑙e喅鏂规浜岋紝鍋囪涓婇潰鐨勪唬鐮佽鎵ц濂介暱鏃堕棿锛岃秴鍑烘垜浠殑瀹瑰繊鑼冨洿锛岄偅鎴戝氨alter table user drop columnscore;alter table user add column score int銆� 涓嬮潰浠g爜瀹炵幇姣忓勾鐨勯偅涓噷鏅ㄦ椂鍒昏繘琛屾竻闆躲�俁unnable runnable =聽 聽 聽 new Runnable(){聽 聽 聽 聽 聽 聽 聽 public voidrun(){聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 clearDb();聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 schedule(this,newDate(new Date().getYear()+1,0,0));聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }; schedule(runnable,聽 聽 聽 new Date(newDate().getYear()+1,0,1)); 19銆佷竴涓敤鎴峰叿鏈夊涓鑹诧紝璇锋煡璇㈠嚭璇ヨ〃涓叿鏈夎鐢ㄦ埛鐨勬墍鏈夎鑹茬殑鍏朵粬鐢ㄦ埛銆俿elect count(*) as num,tb.idfrom tb, (select role from tbwhere id=xxx) as t1where tb.role = t1.role andtb.id != t1.idgroup by tb.idhaving聽 聽 聽 num = select count(role)from tb where id=xxx;20. xxx鍏徃鐨剆ql闈㈣瘯Table EMPLOYEES Structure:EMPLOYEE_ID聽 聽 聽 NUMBER聽 聽 聽 聽 Primary Key,FIRST_NAME聽 聽 聽 VARCHAR2(25),LAST_NAME聽 聽 聽 VARCHAR2(25),Salary number(8,2),HiredDate DATE,Departmentid number(2)TableDepartments Structure:Departmentid number(2)聽 聽 聽 聽 Primary Key,DepartmentName聽 VARCHAR2(25).聽 (2锛夊熀浜庝笂杩癊MPLOYEES琛ㄥ啓鍑烘煡璇細鍐欏嚭闆囩敤鏃ユ湡鍦ㄤ粖骞寸殑锛屾垨鑰呭伐璧勫湪[1000,2000]涔嬮棿鐨勶紝鎴栬�呭憳宸ュ鍚嶏紙last_name锛変互鈥橭bama鈥欐墦澶寸殑鎵�鏈夊憳宸ワ紝鍒楀嚭杩欎簺鍛樺伐鐨勫叏閮ㄤ釜浜轰俊鎭�傦紙4鍒嗭級select* from employeeswhereYear(hiredDate) = Year(date())聽 聽 聽 or (salary between 1000 and 200)聽 聽 聽 or left(last_name,3)='abc'; (3) 鍩轰簬涓婅堪EMPLOYEES琛ㄥ啓鍑烘煡璇細鏌ュ嚭閮ㄩ棬骞冲潎宸ヨ祫澶т簬1800鍏冪殑閮ㄩ棬鐨勬墍鏈夊憳宸ワ紝鍒楀嚭杩欎簺鍛樺伐鐨勫叏閮ㄤ釜浜轰俊鎭�傦紙4鍒嗭級mysql>select id,name,salary,deptid did from employee1 where (select avg(salary) from employee1 where deptid = did) > 1800; (4) 鍩轰簬涓婅堪EMPLOYEES琛ㄥ啓鍑烘煡璇細鏌ュ嚭涓汉宸ヨ祫楂樹簬鍏舵墍鍦ㄩ儴闂ㄥ钩鍧囧伐璧勭殑鍛樺伐锛屽垪鍑鸿繖浜涘憳宸ョ殑鍏ㄩ儴涓汉淇℃伅鍙婅鍛樺伐宸ヨ祫楂樺嚭閮ㄩ棬骞冲潎宸ヨ祫鐧惧垎姣斻�傦紙5鍒嗭級selectemployee1.*,(employee1.salary-t.avgSalary)*100/employee1.salaryfromemployee1,聽 聽 聽 (select deptid,avg(salary) avgSalary fromemployee1 group by deptid) as twhereemployee1.deptid = t.deptid and employee1.salary>t.avgSalary; 21銆佹敞鍐孞dbc椹卞姩绋嬪簭鐨勪笁绉嶆柟寮� 22銆佺敤JDBC濡備綍璋冪敤瀛樺偍杩囩▼浠g爜濡備笅锛歱ackage com.huawei.interview.lym; import java.sql.CallableStatement;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Types; publicclass JdbcTest {聽 聽 /**聽 聽 * @paramargs聽 聽 */聽 聽 public static voidmain(String[] args) {聽 聽 聽 // TODO Auto-generated method stub聽 聽 聽 Connection cn = null;聽 聽 聽 CallableStatement cstmt =null;聽 聽 聽 聽 聽 try {聽 聽 聽 聽 聽 //杩欓噷鏈�濂戒笉瑕佽繖涔堝共锛屽洜涓洪┍鍔ㄥ悕鍐欐鍦ㄧ▼搴忎腑浜喡� 聽 聽 聽 聽 Class.forName("com.mysql.jdbc.Driver");聽 聽 聽 聽 聽 //瀹為檯椤圭洰涓紝杩欓噷搴旂敤DataSource鏁版嵁锛屽鏋滅敤妗嗘灦锛屄� 聽 聽 聽 聽 //杩欎釜鏁版嵁婧愪笉闇�瑕佹垜浠紪鐮佸垱寤猴紝鎴戜滑鍙渶Datasource ds =context.lookup()聽 聽 聽 聽 聽 //cn = ds.getConnection();聽 聽 聽 聽 聽 聽 聽 聽 聽 cn = DriverManager.getConnection("jdbc:mysql:///test","root","root");聽 聽 聽 聽 聽 cstmt = cn.prepareCall("{callinsert_Student(?,?,?)}");聽 聽 聽 聽 聽 cstmt.registerOutParameter(3,Types.INTEGER);聽 聽 聽 聽 聽 cstmt.setString(1,"wangwu");聽 聽 聽 聽 聽 cstmt.setInt(2, 25);聽 聽 聽 聽 聽 cstmt.execute();聽 聽 聽 聽 聽 //get绗嚑涓紝涓嶅悓鐨勬暟鎹簱涓嶄竴鏍凤紝寤鸿涓嶅啓聽 聽 聽 聽 聽 System.out.println(cstmt.getString(3));聽 聽 聽 } catch (Exception e) {聽 聽 聽 聽 聽 // TODO Auto-generated catchblock聽 聽 聽 聽 聽 e.printStackTrace();聽 聽 聽 }聽 聽 聽 finally聽 聽 聽 {聽 聽 聽 聽 聽 聽 /*try{cstmt.close();}catch(Exceptione){}聽 聽 聽 聽 聽 try{cn.close();}catch(Exceptione){}*/聽 聽 聽 聽 聽 try {聽 聽 聽 聽 聽 聽 聽 if(cstmt !=null)聽 聽 聽 聽 聽 聽 聽 聽 聽 cstmt.close();聽 聽 聽 聽 聽 聽 聽 if(cn !=null)聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 cn.close();聽 聽 聽 聽 聽 } catch (SQLException e) {聽 聽 聽 聽 聽 聽 聽 // TODO Auto-generatedcatch block聽 聽 聽 聽 聽 聽 聽 e.printStackTrace();聽 聽 聽 聽 聽 }聽 聽 聽 }聽 聽 }23銆丣DBC涓殑PreparedStatement鐩告瘮Statement鐨勫ソ澶勭瓟锛氫竴涓猻ql鍛戒护鍙戠粰鏈嶅姟鍣ㄥ幓鎵ц鐨勬楠や负锛氳娉曟鏌ワ紝璇箟鍒嗘瀽锛岀紪璇戞垚鍐呴儴鎸囦护锛岀紦瀛樻寚浠わ紝鎵ц鎸囦护绛夎繃绋嬨�俿elect * from student where id =3----缂撳瓨--脿xxxxx浜岃繘鍒跺懡浠elect * from student where id =3----鐩存帴鍙�-脿xxxxx浜岃繘鍒跺懡浠elect * from student where id =4--- -脿浼氭�庝箞骞诧紵濡傛灉褰撳垵鏄痵elect * from student where id =?--- -脿鍙堜細鎬庝箞骞诧紵 涓婇潰璇寸殑鏄�ц兘鎻愰珮鍙互闃叉sql娉ㄥ叆銆�24. 鍐欎竴涓敤jdbc杩炴帴骞惰闂畂racle鏁版嵁鐨勭▼搴忎唬鐮�25銆丆lass.forName鐨勪綔鐢�?涓轰粈涔堣鐢�?绛旓細鎸夊弬鏁颁腑鎸囧畾鐨勫瓧绗︿覆褰㈠紡鐨勭被鍚嶅幓鎼滅储骞跺姞杞界浉搴旂殑绫伙紝濡傛灉璇ョ被瀛楄妭鐮佸凡缁忚鍔犺浇杩囷紝鍒欒繑鍥炰唬琛ㄨ瀛楄妭鐮佺殑Class瀹炰緥瀵硅薄锛屽惁鍒欙紝鎸夌被鍔犺浇鍣ㄧ殑濮旀墭鏈哄埗鍘绘悳绱㈠拰鍔犺浇璇ョ被锛屽鏋滄墍鏈夌殑绫诲姞杞藉櫒閮芥棤娉曞姞杞藉埌璇ョ被锛屽垯鎶涘嚭ClassNotFoundException銆傚姞杞藉畬杩欎釜Class瀛楄妭鐮佸悗锛屾帴鐫�灏卞彲浠ヤ娇鐢–lass瀛楄妭鐮佺殑newInstance鏂规硶鍘诲垱寤鸿绫荤殑瀹炰緥瀵硅薄浜嗐�傛湁鏃跺�欙紝鎴戜滑绋嬪簭涓墍鏈変娇鐢ㄧ殑鍏蜂綋绫诲悕鍦ㄨ璁℃椂锛堝嵆寮�鍙戞椂锛夋棤娉曠‘瀹氾紝鍙湁绋嬪簭杩愯鏃舵墠鑳界‘瀹氾紝杩欐椂鍊欏氨闇�瑕佷娇鐢–lass.forName鍘诲姩鎬佸姞杞借绫伙紝杩欎釜绫诲悕閫氬父鏄湪閰嶇疆鏂囦欢涓厤缃殑锛屼緥濡傦紝spring鐨刬oc涓瘡娆′緷璧栨敞鍏ョ殑鍏蜂綋绫诲氨鏄繖鏍烽厤缃殑锛宩dbc鐨勯┍鍔ㄧ被鍚嶉�氬父涔熸槸閫氳繃閰嶇疆鏂囦欢鏉ラ厤缃殑锛屼互渚垮湪浜у搧浜や粯浣跨敤鍚庝笉鐢ㄤ慨鏀规簮绋嬪簭灏卞彲浠ユ洿鎹㈤┍鍔ㄧ被鍚嶃��26銆佸ぇ鏁版嵁閲忎笅鐨勫垎椤佃В鍐虫柟娉曘�傜瓟锛氭渶濂界殑鍔炴硶鏄埄鐢╯ql璇彞杩涜鍒嗛〉锛岃繖鏍锋瘡娆℃煡璇㈠嚭鐨勭粨鏋滈泦涓氨鍙寘鍚煇椤电殑鏁版嵁鍐呭銆傚啀sql璇彞鏃犳硶瀹炵幇鍒嗛〉鐨勬儏鍐典笅锛屽彲浠ヨ�冭檻瀵瑰ぇ鐨勭粨鏋滈泦閫氳繃娓告爣瀹氫綅鏂瑰紡鏉ヨ幏鍙栨煇椤电殑鏁版嵁銆俿ql璇彞鍒嗛〉锛屼笉鍚岀殑鏁版嵁搴撲笅鐨勫垎椤垫柟妗堝悇涓嶄竴鏍凤紝涓嬮潰鏄富娴佺殑涓夌鏁版嵁搴撶殑鍒嗛〉sql锛歴ql server:聽 聽 聽 String sql =聽 聽 聽 "select top" + pageSize + " * from students where id not in" +聽 "(select top "+ pageSize * (pageNumber-1) + " id from students order by id)" +聽 "order by id"; mysql:聽 聽 聽 聽 String sql =聽 聽 聽 "select * fromstudents order by id limit " + pageSize*(pageNumber-1) + "," +pageSize;聽 聽 聽 oracle:聽 聽 聽 聽 String sql =聽 聽 聽 聽 "select * from " +聽 聽 聽 聽 (select *,rownum rid from (select * fromstudents order by postime desc) where rid<=" + pagesize*pagenumber +") as t" +聽 聽 聽 聽 "where t>" +pageSize*(pageNumber-1);27銆佺敤 JDBC鏌ヨ瀛︾敓鎴愮哗鍗�,鎶婁富瑕佷唬鐮佸啓鍑烘潵锛堣�冭瘯姒傜巼鏋佸ぇ锛�.Connection cn = null;PreparedStatement pstmt =null;Resultset rs = null;try{聽 聽 聽 Class.forname(driveClassName);聽 聽 聽 cn =聽 DriverManager.getConnection(url,username,password);聽 聽 聽 pstmt =cn.prepareStatement(鈥渟elect聽 score.* fromscore ,student 鈥� +聽 聽 聽 聽 聽 聽 聽 鈥渨herescore.stuId = student.id and student.name = ?鈥�);聽 聽 聽 pstmt.setString(1,studentName);聽 聽 聽 Resultset rs =pstmt.executeQuery();聽 聽 聽 while(rs.next())聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 system.out.println(rs.getInt(鈥渟ubject鈥�)聽 +聽 鈥溌� 聽 鈥� + rs.getFloat(鈥渟core鈥�) );聽 聽 聽 }}catch(Exception e){e.printStackTrace();}finally{聽 聽 聽 if(rs != null) try{rs.close() }catch(exception e){}聽 聽 聽 if(pstmt != null)try{pstmt.close()}catch(exception e){}聽 聽 聽 if(cn != null) try{cn.close() }catch(exception e){}}聽 28銆佽繖娈典唬鐮佹湁浠�涔堜笉瓒充箣澶�?try {Connection conn = ...;Statement stmt = ...;ResultSet rs =stmt.executeQuery("select * from table1");while(rs.next()) {}} catch(Exception ex) {}绛旓細娌℃湁finally璇彞鏉ュ叧闂悇涓璞★紝鍙﹀锛屼娇鐢╢inally涔嬪悗锛岃鎶婂彉閲忕殑瀹氫箟鏀惧湪try璇彞鍧楃殑澶栭潰锛屼互渚垮湪try璇彞鍧椾箣澶栫殑finally鍧椾腑浠嶅彲浠ヨ闂繖浜涘彉閲忋�� 29銆佽鍑烘暟鎹繛鎺ユ睜鐨勫伐浣滄満鍒舵槸浠�涔�?J2EE鏈嶅姟鍣ㄥ惎鍔ㄦ椂浼氬缓绔嬩竴瀹氭暟閲忕殑姹犺繛鎺ワ紝骞朵竴鐩寸淮鎸佷笉灏戜簬姝ゆ暟鐩殑姹犺繛鎺ャ�傚鎴风绋嬪簭闇�瑕佽繛鎺ユ椂锛屾睜椹卞姩绋嬪簭浼氳繑鍥炰竴涓湭浣跨敤鐨勬睜杩炴帴骞跺皢鍏惰〃璁颁负蹇欍�傚鏋滃綋鍓嶆病鏈夌┖闂茶繛鎺ワ紝姹犻┍鍔ㄧ▼搴忓氨鏂板缓涓�瀹氭暟閲忕殑杩炴帴锛屾柊寤鸿繛鎺ョ殑鏁伴噺鏈夐厤缃弬鏁板喅瀹氥�傚綋浣跨敤鐨勬睜杩炴帴璋冪敤瀹屾垚鍚庯紝姹犻┍鍔ㄧ▼搴忓皢姝よ繛鎺ヨ〃璁颁负绌洪棽锛屽叾浠栬皟鐢ㄥ氨鍙互浣跨敤杩欎釜杩炴帴銆傚疄鐜版柟寮忥紝杩斿洖鐨凜onnection鏄師濮婥onnection鐨勪唬鐞嗭紝浠g悊Connection鐨刢lose鏂规硶涓嶆槸鐪熸鍏宠繛鎺ワ紝鑰屾槸鎶婂畠浠g悊鐨凜onnection瀵硅薄杩樺洖鍒拌繛鎺ユ睜涓�� 30銆佷负浠�涔堣鐢� ORM? 鍜� JDBC鏈変綍涓嶄竴鏍�?orm鏄竴绉嶆�濇兂锛屽氨鏄妸object杞彉鎴愭暟鎹簱涓殑璁板綍锛屾垨鑰呮妸鏁版嵁搴撲腑鐨勮褰曡浆鍙樻垚objecdt锛屾垜浠彲浠ョ敤jdbc鏉ュ疄鐜拌繖绉嶆�濇兂锛屽叾瀹烇紝濡傛灉鎴戜滑鐨勯」鐩槸涓ユ牸鎸夌収oop鏂瑰紡缂栧啓鐨勮瘽锛屾垜浠殑jdbc绋嬪簭涓嶇鏄湁鎰忚繕鏄棤鎰忥紝灏卞凡缁忓湪瀹炵幇orm鐨勫伐浣滀簡銆傜幇鍦ㄦ湁璁稿orm宸ュ叿锛屽畠浠簳灞傝皟鐢╦dbc鏉ュ疄鐜颁簡orm宸ヤ綔锛屾垜浠洿鎺ヤ娇鐢ㄨ繖浜涘伐鍏凤紝灏辩渷鍘讳簡鐩存帴浣跨敤jdbc鐨勭箒鐞愮粏鑺傦紝鎻愰珮浜嗗紑鍙戞晥鐜囷紝鐜板湪鐢ㄧ殑杈冨鐨刼rm宸ュ叿鏄痟ibernate銆備篃鍚涓�浜涘叾浠杘rm宸ュ叿锛屽toplink,ojb绛夈�傚叚. XML閮ㄥ垎1銆亁ml鏈夊摢浜涜В鏋愭妧鏈�?鍖哄埆鏄粈涔�?绛�:鏈塂OM,SAX,STAX绛塂OM:澶勭悊澶у瀷鏂囦欢鏃跺叾鎬ц兘涓嬮檷鐨勯潪甯稿帀瀹炽�傝繖涓棶棰樻槸鐢盌OM鐨勬爲缁撴瀯鎵�閫犳垚鐨勶紝杩欑缁撴瀯鍗犵敤鐨勫唴瀛樿緝澶氾紝鑰屼笖DOM蹇呴』鍦ㄨВ鏋愭枃浠朵箣鍓嶆妸鏁翠釜鏂囨。瑁呭叆鍐呭瓨,閫傚悎瀵筙ML鐨勯殢鏈鸿闂甋AX:涓嶇幇浜嶥OM,SAX鏄簨浠堕┍鍔ㄥ瀷鐨刋ML瑙f瀽鏂瑰紡銆傚畠椤哄簭璇诲彇XML鏂囦欢锛屼笉闇�瑕佷竴娆″叏閮ㄨ杞芥暣涓枃浠躲�傚綋閬囧埌鍍忔枃浠跺紑澶达紝鏂囨。缁撴潫锛屾垨鑰呮爣绛惧紑澶翠笌鏍囩缁撴潫鏃讹紝瀹冧細瑙﹀彂涓�涓簨浠讹紝鐢ㄦ埛閫氳繃鍦ㄥ叾鍥炶皟浜嬩欢涓啓鍏ュ鐞嗕唬鐮佹潵澶勭悊XML鏂囦欢锛岄�傚悎瀵筙ML鐨勯『搴忚闂甋TAX:Streaming API for XML (StAX)璁茶В杩欎簺鍖哄埆鏄笉闇�瑕佺壒鍒幓姣旇緝锛屽氨鍍忚浼犳櫤鎾涓庡叾浠栧煿璁満鏋勭殑鍖哄埆鏃讹紝鎴戜滑鍙渶璇存竻妤氫紶鏅烘挱瀹㈡湁浠�涔堢壒鐐瑰拰浼樼偣灏辫浜嗭紝杩欏氨宸茬粡闂存帴鍥炵瓟浜嗗郊姝ょ殑鍖哄埆銆� 2銆佷綘鍦ㄩ」鐩腑鐢ㄥ埌浜唜ml鎶�鏈殑鍝簺鏂归潰?濡備綍瀹炵幇鐨�?绛�:鐢ㄥ埌浜嗘暟鎹瓨璐紝淇℃伅閰嶇疆涓ゆ柟闈€�傚湪鍋氭暟鎹氦鎹㈠钩鍙版椂锛屽皢涓嶈兘鏁版嵁婧愮殑鏁版嵁缁勮鎴怷ML鏂囦欢锛岀劧鍚庡皢XML鏂囦欢鍘嬬缉鎵撳寘鍔犲瘑鍚庨�氳繃缃戠粶浼犻�佺粰鎺ユ敹鑰咃紝鎺ユ敹瑙e瘑涓庤В鍘嬬缉鍚庡啀鍚孹ML鏂囦欢涓繕鍘熺浉鍏充俊鎭繘琛屽鐞嗐�傚湪鍋氳蒋浠堕厤缃椂锛屽埄鐢╔ML鍙互寰堟柟渚跨殑杩涜锛岃蒋浠剁殑鍚勭閰嶇疆鍙傛暟閮藉瓨璐湪XML鏂囦欢涓��3銆佺敤jdom瑙f瀽xml鏂囦欢鏃跺浣曡В鍐充腑鏂囬棶棰�?濡備綍瑙f瀽?绛�:鐪嬪涓嬩唬鐮�,鐢ㄧ紪鐮佹柟寮忓姞浠ヨВ鍐硃ackage test; import java.io.*; public class DOMTest { private String inFile = "c:\\people.xml" private String outFile = "c:\\people.xml" public static void main(String args[]) { new DOMTest(); } public DOMTest() { try { javax.xml.parsers.DocumentBuilder builder =javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();org.w3c.dom.Document doc = builder.newDocument(); org.w3c.dom.Element root = doc.createElement("鑰佸笀");org.w3c.dom.Element wang = doc.createElement("鐜�");org.w3c.dom.Element liu = doc.createElement("鍒�");wang.appendChild(doc.createTextNode("鎴戞槸鐜嬭�佸笀"));root.appendChild(wang); doc.appendChild(root); javax.xml.transform.Transformer transformer = javax.xml.transform.TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING,"gb2312"); transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT,"yes");transformer.transform(newjavax.xml.transform.dom.DOMSource(doc),newjavax.xml.transform.stream.StreamResult(outFile));} catch (Exception e) { System.out.println (e.getMessage()); } } }4銆佺紪绋嬬敤JAVA瑙f瀽XML鐨勬柟寮�.绛�:鐢⊿AX鏂瑰紡瑙f瀽XML锛孹ML鏂囦欢濡備笅锛氱帇灏忔槑淇℃伅瀛﹂櫌6258113鐢�,1955骞寸敓,鍗氬+锛�95骞磋皟鍏ユ捣鍗楀ぇ瀛︿簨浠跺洖璋冪被SAXHandler.javaimport java.io.*;import java.util.Hashtable;import org.xml.sax.*;public class SAXHandler extends HandlerBase{private Hashtable table = new Hashtable();private String currentElement = null;private String currentValue = null;public void setTable(Hashtable table){this.table = table;}public Hashtable getTable(){return table;}public void startElement(String tag, AttributeList attrs)throws SAXException{currentElement = tag;}public void characters(char[] ch, int start, int length)throws SAXException{currentValue = new String(ch, start, length);}public void endElement(String name) throws SAXException{if (currentElement.equals(name))table.put(currentElement, currentValue);} }JSP鍐呭鏄剧ず婧愮爜,SaxXml.jsp:<%@ page errorPage=ErrPage.jspcontentType=text/html;charset=GB2312 %><%@ page import=java.io.* %><%@ page import=java.util.Hashtable %><%@ page import=org.w3c.dom.* %><%@ page import=org.xml.sax.* %><%@ page import=javax.xml.parsers.SAXParserFactory %><%@ page import=javax.xml.parsers.SAXParser %><%@ page import=SAXHandler %><%File file = new File(c:\people.xml);FileReader reader = new FileReader(file);Parser parser;SAXParserFactory spf = SAXParserFactory.newInstance();SAXParser sp = spf.newSAXParser();SAXHandler handler = new SAXHandler();sp.parse(new InputSource(reader), handler);Hashtable hashTable = handler.getTable();out.println();out.println( + );out.println( + );out.println( + );out.println( + );out.println(
鏁欏笀淇℃伅琛�
濮撳悕+
(String)hashTable.get(new String(name)) +
瀛﹂櫌+
(String)hashTable.get(newString(college))+
鐢佃瘽+
(String)hashTable.get(new String(telephone)) +
澶囨敞+
(String)hashTable.get(new String(notes)) +
);%>5銆乆ML鏂囨。瀹氫箟鏈夊嚑绉嶅舰寮忥紵瀹冧滑涔嬮棿鏈変綍鏈川鍖哄埆锛熻В鏋怷ML鏂囨。鏈夊摢鍑犵鏂瑰紡锛焌: 涓ょ褰㈠紡 dtd schema锛宐:鏈川鍖哄埆:schema鏈韩鏄痻ml鐨勶紝鍙互琚玐ML瑙f瀽鍣ㄨВ鏋�(杩欎篃鏄粠DTD涓婂彂灞晄chema鐨勬牴鏈洰鐨�)锛宑:鏈塂OM,SAX,STAX绛壜� DOM:澶勭悊澶у瀷鏂囦欢鏃跺叾鎬ц兘涓嬮檷鐨勯潪甯稿帀瀹炽�傝繖涓棶棰樻槸鐢盌OM鐨勬爲缁撴瀯鎵�閫犳垚鐨勶紝杩欑缁撴瀯鍗犵敤鐨勫唴瀛樿緝澶氾紝鑰屼笖DOM蹇呴』鍦ㄨВ鏋愭枃浠朵箣鍓嶆妸鏁翠釜鏂囨。瑁呭叆鍐呭瓨,閫傚悎瀵筙ML鐨勯殢鏈鸿闂甋AX:涓嶇幇浜嶥OM,SAX鏄簨浠堕┍鍔ㄥ瀷鐨刋ML瑙f瀽鏂瑰紡銆傚畠椤哄簭璇诲彇XML鏂囦欢锛屼笉闇�瑕佷竴娆″叏閮ㄨ杞芥暣涓枃浠躲�傚綋閬囧埌鍍忔枃浠跺紑澶达紝鏂囨。缁撴潫锛屾垨鑰呮爣绛惧紑澶翠笌鏍囩缁撴潫鏃讹紝瀹冧細瑙﹀彂涓�涓簨浠讹紝鐢ㄦ埛閫氳繃鍦ㄥ叾鍥炶皟浜嬩欢涓啓鍏ュ鐞嗕唬鐮佹潵澶勭悊XML鏂囦欢锛岄�傚悎瀵筙ML鐨勯『搴忚闂� STAX:Streaming API forXML (StAX) 涓�.娴佽鐨勬鏋朵笌鏂版妧鏈�1銆佽皥璋堜綘瀵筍truts鐨勭悊瑙c�傜瓟:1. struts鏄竴涓寜MVC妯″紡璁捐鐨刉eb灞傛鏋讹紝鍏跺疄瀹冨氨鏄竴涓ぇ澶х殑servlet锛岃繖涓猄ervlet鍚嶄负ActionServlet锛屾垨鏄疉ctionServlet鐨勫瓙绫汇�傛垜浠彲浠ュ湪web.xml鏂囦欢涓皢绗﹀悎鏌愮鐗瑰緛鐨勬墍鏈夎姹備氦缁欒繖涓猄ervlet澶勭悊锛岃繖涓猄ervlet鍐嶅弬鐓т竴涓厤缃枃浠讹紙閫氬父涓�/WEB-INF/struts-config.xml锛夊皢鍚勪釜璇锋眰鍒嗗埆鍒嗛厤缁欎笉鍚岀殑action鍘诲鐞嗐�備竴涓墿灞曠煡璇嗙偣锛歴truts鐨勯厤缃枃浠跺彲浠ユ湁澶氫釜锛屽彲浠ユ寜妯″潡閰嶇疆鍚勮嚜鐨勯厤缃枃浠讹紝杩欐牱鍙互闃叉閰嶇疆鏂囦欢鐨勮繃搴﹁啫鑳�锛�2.ActionServlet鎶婅姹備氦缁檃ction鍘诲鐞嗕箣鍓嶏紝浼氬皢璇锋眰鍙傛暟灏佽鎴愪竴涓猣ormbean瀵硅薄锛堝氨鏄竴涓猨ava绫伙紝杩欎釜绫讳腑鐨勬瘡涓睘鎬у搴斾竴涓姹傚弬鏁帮級锛屽皝瑁呮垚涓�涓粈涔堟牱鐨刦ormbean瀵硅薄鍛紵鐪嬮厤缃枃浠躲��3.瑕佽鏄庣殑鏄紝 ActionServlet鎶奻ormbean瀵硅薄浼犻�掔粰action鐨別xecute鏂规硶涔嬪墠锛屽彲鑳戒細璋冪敤formbean鐨剉alidate鏂规硶杩涜鏍¢獙锛屽彧鏈夋牎楠岄�氳繃鍚庢墠灏嗚繖涓猣ormbean瀵硅薄浼犻�掔粰action鐨別xecute鏂规硶锛屽惁鍒欙紝瀹冨皢杩斿洖涓�涓敊璇〉闈紝杩欎釜閿欒椤甸潰鐢眎nput灞炴�ф寚瀹氾紝锛堢湅閰嶇疆鏂囦欢锛変綔鑰呬负浠�涔堝皢杩欓噷鍛藉悕涓篿nput灞炴�э紝鑰屼笉鏄痚rror灞炴�э紝鎴戜滑鍚庨潰缁撳悎瀹為檯鐨勮繍琛屾晥鏋滆繘琛屽垎鏋愩��4.action鎵ц瀹屽悗瑕佽繑鍥炴樉绀虹殑缁撴灉瑙嗗浘锛岃繖涓粨鏋滆鍥炬槸鐢ㄤ竴涓狝ctionForward瀵硅薄鏉ヨ〃绀虹殑锛宎ctionforward瀵硅薄閫氳繃struts-config.xml閰嶇疆鏂囦欢涓殑閰嶇疆鍏宠仈鍒版煇涓猨sp椤甸潰锛屽洜涓虹▼搴忎腑浣跨敤鐨勬槸鍦╯truts-config.xml閰嶇疆鏂囦欢涓簀sp椤甸潰璁剧疆鐨勯�昏緫鍚嶏紝杩欐牱鍙互瀹炵幇action绋嬪簭浠g爜涓庤繑鍥炵殑jsp椤甸潰鍚嶇О鐨勮В鑰︺�� 浣犲struts鍙兘杩樻湁鑷繁鐨勫簲鐢ㄦ柟闈㈢殑缁忛獙锛岄偅涔熻涓�骞惰鍑烘潵銆�2銆佽皥璋堜綘瀵笻ibernate鐨勭悊瑙c�傜瓟:1. 闈㈠悜瀵硅薄璁捐鐨勮蒋浠跺唴閮ㄨ繍琛岃繃绋嬪彲浠ョ悊瑙f垚灏辨槸鍦ㄤ笉鏂垱寤哄悇绉嶆柊瀵硅薄銆佸缓绔嬪璞′箣闂寸殑鍏崇郴锛岃皟鐢ㄥ璞$殑鏂规硶鏉ユ敼鍙樺悇涓璞$殑鐘舵�佸拰瀵硅薄娑堜骸鐨勮繃绋嬶紝涓嶇绋嬪簭杩愯鐨勮繃绋嬪拰鎿嶄綔鎬庝箞鏍凤紝鏈川涓婇兘鏄寰楀埌涓�涓粨鏋滐紝绋嬪簭涓婁竴涓椂鍒诲拰涓嬩竴涓椂鍒荤殑杩愯缁撴灉鐨勫樊寮傚氨琛ㄧ幇鍦ㄥ唴瀛樹腑鐨勫璞$姸鎬佸彂鐢熶簡鍙樺寲銆�2.涓轰簡鍦ㄥ叧鏈哄拰鍐呭瓨绌洪棿涓嶅鐨勭姸鍐典笅锛屼繚鎸佺▼搴忕殑杩愯鐘舵�侊紝闇�瑕佸皢鍐呭瓨涓殑瀵硅薄鐘舵�佷繚瀛樺埌鎸佷箙鍖栬澶囧拰浠庢寔涔呭寲璁惧涓仮澶嶅嚭瀵硅薄鐨勭姸鎬侊紝閫氬父閮芥槸淇濆瓨鍒板叧绯绘暟鎹簱鏉ヤ繚瀛樺ぇ閲忓璞′俊鎭�備粠Java绋嬪簭鐨勮繍琛屽姛鑳戒笂鏉ヨ锛屼繚瀛樺璞$姸鎬佺殑鍔熻兘鐩告瘮绯荤粺杩愯鐨勫叾浠栧姛鑳芥潵璇达紝搴旇鏄竴涓緢涓嶈捣鐪肩殑闄勫睘鍔熻兘锛宩ava閲囩敤jdbc鏉ュ疄鐜拌繖涓姛鑳斤紝杩欎釜涓嶈捣鐪肩殑鍔熻兘鍗磋缂栧啓澶ч噺鐨勪唬鐮侊紝鑰屽仛鐨勪簨鎯呬粎浠呮槸淇濆瓨瀵硅薄鍜屾仮澶嶅璞★紝骞朵笖閭d簺澶ч噺鐨刯dbc浠g爜骞舵病鏈変粈涔堟妧鏈惈閲忥紝鍩烘湰涓婃槸閲囩敤涓�濂椾緥琛屽叕浜嬬殑鏍囧噯浠g爜妯℃澘鏉ョ紪鍐欙紝鏄竴绉嶈嫤娲诲拰閲嶅鎬х殑宸ヤ綔銆�3.閫氳繃鏁版嵁搴撲繚瀛榡ava绋嬪簭杩愯鏃朵骇鐢熺殑瀵硅薄鍜屾仮澶嶅璞★紝鍏跺疄灏辨槸瀹炵幇浜唈ava瀵硅薄涓庡叧绯绘暟鎹簱璁板綍鐨勬槧灏勫叧绯伙紝绉颁负ORM锛堝嵆Object Relation Mapping锛夛紝浜轰滑鍙互閫氳繃灏佽JDBC浠g爜鏉ュ疄鐜颁簡杩欑鍔熻兘锛屽皝瑁呭嚭鏉ョ殑浜у搧绉颁箣涓篛RM妗嗘灦锛孒ibernate灏辨槸鍏朵腑鐨勪竴绉嶆祦琛孫RM妗嗘灦銆備娇鐢℉ibernate妗嗘灦锛屼笉鐢ㄥ啓JDBC浠g爜锛屼粎浠呮槸璋冪敤涓�涓猻ave鏂规硶锛屽氨鍙互灏嗗璞′繚瀛樺埌鍏崇郴鏁版嵁搴撲腑锛屼粎浠呮槸璋冪敤涓�涓猤et鏂规硶锛屽氨鍙互浠庢暟鎹簱涓姞杞藉嚭涓�涓璞°��4.浣跨敤Hibernate鐨勫熀鏈祦绋嬫槸锛氶厤缃瓹onfiguration瀵硅薄銆佷骇鐢烻essionFactory銆佸垱寤簊ession瀵硅薄锛屽惎鍔ㄤ簨鍔★紝瀹屾垚CRUD鎿嶄綔锛屾彁浜や簨鍔★紝鍏抽棴session銆�5.浣跨敤Hibernate鏃讹紝鍏堣閰嶇疆hibernate.cfg.xml鏂囦欢锛屽叾涓厤缃暟鎹簱杩炴帴淇℃伅鍜屾柟瑷�绛夛紝杩樿涓烘瘡涓疄浣撻厤缃浉搴旂殑hbm.xml鏂囦欢锛宧ibernate.cfg.xml鏂囦欢涓渶瑕佺櫥璁版瘡涓猦bm.xml鏂囦欢銆�6.鍦ㄥ簲鐢℉ibernate鏃讹紝閲嶇偣瑕佷簡瑙ession鐨勭紦瀛樺師鐞嗭紝绾ц仈锛屽欢杩熷姞杞藉拰hql鏌ヨ銆�3銆丄OP鐨勪綔鐢ㄣ��4銆佷綘瀵筍pring鐨勭悊瑙c��1.Spring瀹炵幇浜嗗伐鍘傛ā寮忕殑宸ュ巶绫伙紙鍦ㄨ繖閲屾湁蹇呰瑙i噴娓呮浠�涔堟槸宸ュ巶妯″紡锛夛紝杩欎釜绫诲悕涓築eanFactory锛堝疄闄呬笂鏄竴涓帴鍙o級锛屽湪绋嬪簭涓�氬父BeanFactory鐨勫瓙绫籄pplicationContext銆係pring鐩稿綋浜庝竴涓ぇ鐨勫伐鍘傜被锛屽湪鍏堕厤缃枃浠朵腑閫氳繃鍏冪礌閰嶇疆鐢ㄤ簬鍒涘缓瀹炰緥瀵硅薄鐨勭被鍚嶅拰瀹炰緥瀵硅薄鐨勫睘鎬с��2. Spring鎻愪緵浜嗗IOC鑹ソ鏀寔锛孖OC鏄竴绉嶇紪绋嬫�濇兂锛屾槸涓�绉嶆灦鏋勮壓鏈紝鍒╃敤杩欑鎬濇兂鍙互寰堝ソ鍦板疄鐜版ā鍧椾箣闂寸殑瑙h�︺�侷OC涔熺О涓篋I锛圖epency Injection锛夛紝浠�涔堝彨渚濊禆娉ㄥ叆鍛紵璀锛孋lass Programmer{聽 聽 聽 Computer computer =null;聽 聽 聽 public void code()聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 //Computercomputer = new IBMComputer();聽 聽 聽 聽 聽 聽 聽 //Computercomputer = beanfacotry.getComputer();聽 聽 聽 聽 聽 聽 聽 computer.write();聽 聽 聽 }聽 聽 聽 public voidsetComputer(Computer computer)聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 this.computer= computer;聽 聽 聽 }}鍙﹀涓ょ鏂瑰紡閮界敱渚濊禆锛岀涓�涓洿鎺ヤ緷璧栦簬鐩爣绫伙紝绗簩涓妸渚濊禆杞Щ鍒板伐鍘備笂锛岀涓変釜褰诲簳涓庣洰鏍囧拰宸ュ巶瑙h�︿簡銆傚湪spring鐨勯厤缃枃浠朵腑閰嶇疆鐗囨濡備笅锛�3. Spring鎻愪緵浜嗗AOP鎶�鏈殑鑹ソ灏佽锛� AOP绉颁负闈㈠悜鍒囬潰缂栫▼锛屽氨鏄郴缁熶腑鏈夊緢澶氬悇涓嶇浉骞茬殑绫荤殑鏂规硶锛屽湪杩欎簺浼楀鏂规硶涓鍔犲叆鏌愮绯荤粺鍔熻兘鐨勪唬鐮侊紝渚嬪锛屽姞鍏ユ棩蹇楋紝鍔犲叆鏉冮檺鍒ゆ柇锛屽姞鍏ュ紓甯稿鐞嗭紝杩欑搴旂敤绉颁负AOP銆傚疄鐜癆OP鍔熻兘閲囩敤鐨勬槸浠g悊鎶�鏈紝瀹㈡埛绔▼搴忎笉鍐嶈皟鐢ㄧ洰鏍囷紝鑰岃皟鐢ㄤ唬鐞嗙被锛屼唬鐞嗙被涓庣洰鏍囩被瀵瑰鍏锋湁鐩稿悓鐨勬柟娉曞0鏄庯紝鏈変袱绉嶆柟寮忓彲浠ュ疄鐜扮浉鍚岀殑鏂规硶澹版槑锛屼竴鏄疄鐜扮浉鍚岀殑鎺ュ彛锛屼簩鏄綔涓虹洰鏍囩殑瀛愮被鍦紝JDK涓噰鐢≒roxy绫讳骇鐢熷姩鎬佷唬鐞嗙殑鏂瑰紡涓烘煇涓帴鍙g敓鎴愬疄鐜扮被锛屽鏋滆涓烘煇涓被鐢熸垚瀛愮被锛屽垯鍙互鐢–GLI B銆傚湪鐢熸垚鐨勪唬鐞嗙被鐨勬柟娉曚腑鍔犲叆绯荤粺鍔熻兘鍜岃皟鐢ㄧ洰鏍囩被鐨勭浉搴旀柟娉曪紝绯荤粺鍔熻兘鐨勪唬鐞嗕互Advice瀵硅薄杩涜鎻愪緵锛屾樉鐒惰鍒涘缓鍑轰唬鐞嗗璞★紝鑷冲皯闇�瑕佺洰鏍囩被鍜孉dvice绫汇�俿pring鎻愪緵浜嗚繖绉嶆敮鎸侊紝鍙渶瑕佸湪spring閰嶇疆鏂囦欢涓厤缃繖涓や釜鍏冪礌鍗冲彲瀹炵幇浠g悊鍜宎op鍔熻兘锛屼緥濡傦紝5銆佽皥璋圫truts涓殑Action servlet銆�6銆丼truts浼樼己鐐逛紭鐐癸細1. 瀹炵幇MVC妯″紡锛岀粨鏋勬竻鏅�,浣垮紑鍙戣�呭彧鍏虫敞涓氬姟閫昏緫鐨勫疄鐜�.2锛庢湁涓板瘜鐨則ag鍙互鐢� ,Struts鐨勬爣璁板簱(Taglib)锛屽鑳界伒娲诲姩鐢紝鍒欒兘澶уぇ鎻愰珮寮�鍙戞晥鐜�3. 椤甸潰瀵艰埅聽 聽 聽 浣跨郴缁熺殑鑴夌粶鏇村姞娓呮櫚銆傞�氳繃涓�涓厤缃枃浠讹紝鍗冲彲鎶婃彙鏁翠釜绯荤粺鍚勯儴鍒嗕箣闂寸殑鑱旂郴锛岃繖瀵逛簬鍚庢湡鐨勭淮鎶ゆ湁鐫�鑾ぇ鐨勫ソ澶勩�傚挨鍏舵槸褰撳彟涓�鎵瑰紑鍙戣�呮帴鎵嬭繖涓」鐩椂锛岃繖绉嶄紭鍔夸綋鐜板緱鏇村姞鏄庢樉銆�4. 鎻愪緵Exception澶勭悊鏈哄埗 .5. 鏁版嵁搴撻摼鎺ユ睜绠$悊6. 鏀寔I18N缂虹偣涓�銆伮� 杞埌灞曠ず灞傛椂锛岄渶瑕侀厤缃甪orward锛屽鏋滄湁鍗佷釜灞曠ず灞傜殑jsp锛岄渶瑕侀厤缃崄娆truts锛岃�屼笖杩樹笉鍖呮嫭鏈夋椂鍊欑洰褰曘�佹枃浠跺彉鏇达紝闇�瑕侀噸鏂颁慨鏀筬orward锛屾敞鎰忥紝姣忔淇敼閰嶇疆涔嬪悗锛岃姹傞噸鏂伴儴缃叉暣涓」鐩紝鑰宼omcate杩欐牱鐨勬湇鍔″櫒锛岃繕蹇呴』閲嶆柊鍚姩鏈嶅姟鍣ㄤ簩銆伮� 浜屻�� Struts鐨凙ction蹇呴渶鏄痶hread锛峴afe鏂瑰紡锛屽畠浠呬粎鍏佽涓�涓疄渚嬪幓澶勭悊鎵�鏈夌殑璇锋眰銆傛墍浠ction鐢ㄥ埌鐨勬墍鏈夌殑璧勬簮閮藉繀闇�缁熶竴鍚屾锛岃繖涓氨寮曡捣浜嗙嚎绋嬪畨鍏ㄧ殑闂銆備笁銆伮� 聽 娴嬭瘯涓嶆柟渚�. Struts鐨勬瘡涓狝ction閮藉悓Web灞傝�﹀悎鍦ㄤ竴璧凤紝杩欐牱瀹冪殑娴嬭瘯渚濊禆浜嶹eb瀹瑰櫒锛屽崟鍏冩祴璇曚篃寰堥毦瀹炵幇銆備笉杩囨湁涓�涓狫unit鐨勬墿灞曞伐鍏稴truts TestCase鍙互瀹炵幇瀹冪殑鍗曞厓娴嬭瘯銆傚洓銆伮� 聽 绫诲瀷鐨勮浆鎹�. Struts鐨凢ormBean鎶婃墍鏈夌殑鏁版嵁閮戒綔涓篠tring绫诲瀷锛屽畠鍙互浣跨敤宸ュ叿Commons-Beanutils杩涜绫诲瀷杞寲銆備絾瀹冪殑杞寲閮芥槸鍦–lass绾у埆锛岃�屼笖杞寲鐨勭被鍨嬫槸涓嶅彲閰嶇疆鐨勩�傜被鍨嬭浆鍖栨椂鐨勯敊璇俊鎭繑鍥炵粰鐢ㄦ埛涔熸槸闈炲父鍥伴毦鐨勩�備簲銆伮� 瀵筍ervlet鐨勪緷璧栨�ц繃寮�. Struts澶勭悊Action鏃跺繀闇�瑕佷緷璧朣ervletRequest鍜孲ervletResponse锛屾墍鏈夊畠鎽嗚劚涓嶄簡Servlet瀹瑰櫒銆傚叚銆伮� 聽 鍓嶇琛ㄨ揪寮忚瑷�鏂归潰.Struts闆嗘垚浜咼STL锛屾墍浠ュ畠涓昏浣跨敤JSTL鐨勮〃杈惧紡璇█鏉ヨ幏鍙栨暟鎹�傚彲鏄疛STL鐨勮〃杈惧紡璇█鍦–ollection鍜岀储寮曞睘鎬ф柟闈㈠鐞嗘樉寰楀緢寮便�備竷銆伮� 聽 瀵笰ction鎵ц鐨勬帶鍒跺洶闅�. Struts鍒涘缓涓�涓狝ction锛屽鏋滄兂鎺у埗瀹冪殑鎵ц椤哄簭灏嗕細闈炲父鍥伴毦銆傜敋鑷充綘瑕侀噸鏂板幓鍐橲ervlet鏉ュ疄鐜颁綘鐨勮繖涓姛鑳介渶姹傘�傚叓銆伮� 聽 瀵笰ction鎵ц鍓嶅拰鍚庣殑澶勭悊. Struts澶勭悊Action鐨勬椂鍊欐槸鍩轰簬class鐨刪ierarchies锛屽緢闅惧湪action澶勭悊鍓嶅拰鍚庤繘琛屾搷浣溿�備節銆伮� 聽 瀵逛簨浠舵敮鎸佷笉澶�.鍦╯truts涓紝瀹為檯鏄竴涓〃鍗旻orm瀵瑰簲涓�涓狝ction绫�(鎴朌ispatchAction)锛屾崲涓�鍙ヨ瘽璇达細鍦⊿truts涓疄闄呮槸涓�涓〃鍗曞彧鑳藉搴斾竴涓簨浠讹紝struts杩欑浜嬩欢鏂瑰紡绉颁负application event锛宎pplication event鍜宑omponent event鐩告瘮鏄竴绉嶇矖绮掑害鐨勪簨浠堵� 7銆丼TRUTS鐨勫簲鐢�(濡係TRUTS鏋舵瀯)Struts鏄噰鐢↗ava Servlet/JavaServer Pages鎶�鏈紝寮�鍙慦eb搴旂敤绋嬪簭鐨勫紑鏀炬簮鐮佺殑framework銆傞噰鐢⊿truts鑳藉紑鍙戝嚭鍩轰簬MVC(Model-View-Controller)璁捐妯″紡鐨勫簲鐢ㄦ瀯鏋躲�� Struts鏈夊涓嬬殑涓昏鍔熻兘锛氫竴.鍖呭惈涓�涓猚ontroller servlet锛岃兘灏嗙敤鎴风殑璇锋眰鍙戦�佸埌鐩稿簲鐨凙ction瀵硅薄銆備簩.JSP鑷敱tag搴擄紝骞朵笖鍦╟ontroller servlet涓彁渚涘叧鑱旀敮鎸侊紝甯姪寮�鍙戝憳鍒涘缓浜や簰寮忚〃鍗曞簲鐢ㄣ�備笁.鎻愪緵浜嗕竴绯诲垪瀹炵敤瀵硅薄锛歑ML澶勭悊銆侀�氳繃Java reflection APIs鑷姩澶勭悊JavaBeans灞炴�с�佸浗闄呭寲鐨勬彁绀哄拰娑堟伅銆� 8銆佽璇磗truts1涓巗truts2鐨勫尯鍒��1.閮芥槸MVC鐨刉EB妗嗘灦,2 struts1鐨勮�佺墝妗嗘灦锛屽簲鐢ㄥ緢骞挎硾锛屾湁寰堝ソ鐨勭兢浼楀熀纭�锛屼娇鐢ㄥ畠寮�鍙戦闄╁緢灏忥紝鎴愭湰鏇翠綆锛乻truts2铏界劧鍩轰簬杩欎釜妗嗘灦锛屼絾鏄簲鐢ㄧ兢浼楀苟澶氾紝鐩稿涓嶆垚鐔燂紝鏈煡鐨勯闄╁拰鍙樺寲寰堝锛屽紑鍙戜汉鍛樼浉瀵逛笉濂芥嫑锛屼娇鐢ㄥ畠寮�鍙戦」鐩殑椋庨櫓绯绘暟鏇村ぇ锛岀敤浜烘垚鏈洿楂橈紒3.struts2姣曠珶鏄珯鍦ㄥ墠杈堢殑鍩虹璁捐鍑烘潵锛屽畠浼氭敼鍠勫拰瀹屽杽struts1涓殑涓�浜涚己闄凤紝struts1涓竴浜涙偓鑰屾湭鍐抽棶棰樺湪struts2寰楀埌浜嗚В鍐炽��4.struts1鐨勫墠绔帶鍒跺櫒鏄竴涓猄ervlet锛屽悕绉颁负ActionServlet锛宻truts2鐨勫墠绔帶鍒跺櫒鏄竴涓猣ilter锛屽湪struts2.0涓彨FilterDispatcher锛屽湪struts2.1涓彨StrutsPrepareAndExecuteFilter銆�5.struts1鐨刟ction闇�瑕佺户鎵緼ction绫伙紝struts2鐨刟ction鍙互涓嶇户鎵夸换浣曠被锛泂truts1瀵瑰悓涓�涓矾寰勭殑鎵�鏈夎姹傚叡浜竴涓狝ction瀹炰緥锛宻truts2瀵瑰悓涓�涓矾寰勭殑姣忎釜璇锋眰鍒嗗埆浣跨敤涓�涓嫭绔婣ction瀹炰緥瀵硅薄锛屾墍鏈夊浜巗truts2鐨凙ction涓嶇敤鑰冭檻绾跨▼瀹夊叏闂銆�6.鍦╯truts1涓娇鐢╢ormbean灏佽璇锋眰鍙傛暟锛屽湪struts2涓洿鎺ヤ娇鐢╝ction鐨勫睘鎬ф潵灏佽璇锋眰鍙傛暟銆�7.struts1涓殑澶氫釜涓氬姟鏂规硶鏀惧湪涓�涓狝ction涓椂锛堝嵆缁ф壙DispatchAction鏃讹級锛岃涔堥兘鏍¢獙锛岃涔堥兘涓嶆牎楠岋紱瀵逛簬struts2锛屽彲浠ユ寚瀹氬彧瀵规煇涓柟娉曡繘琛屾牎楠岋紝褰撲竴涓狝ction缁ф壙浜咥ctionSupport涓斿湪杩欎釜绫讳腑鍙紪鍐欎簡validateXxx()鏂规硶锛岄偅涔堝垯鍙Xxx()鏂规硶杩涜鏍¢獙銆� 锛堜竴涓姹傛潵浜嗙殑鎵ц娴佺▼杩涜鍒嗘瀽锛宻truts2鏄嚜鍔ㄦ敮鎸佸垎妯″潡寮�鍙戯紝骞跺彲浠ヤ笉鍚屾ā鍧楄缃笉鍚岀殑url鍓嶇紑锛岃繖鏄�氳繃package鐨刵amespace鏉ュ疄鐜扮殑锛泂truts2鏄敮鎸佸绉嶇被鍨嬬殑瑙嗗浘锛泂truts2鐨勮鍥惧湴鍧�鍙互鏄姩鎬佺殑锛屽嵆瑙嗗浘鐨勫悕绉版槸鏀寔鍙橀噺鏂瑰紡鐨勶紝涓句緥锛岃鍧涘彂甯栧け璐ュ悗鍥炴潵杩樿浼犻�抌oardid銆傝鍥惧唴瀹规樉绀烘柟闈細瀹冪殑鏍囩鐢╫gnl锛岃el寮哄ぇ寰堝锛屽湪鍥介檯鍖栨柟闈㈡敮鎸佸垎妯″潡绠$悊锛屼袱涓ā鍧楃敤鍒板悓鏍风殑key锛屽搴斾笉鍚岀殑娑堟伅锛涳級聽 聽 聽 聽 涓嶴truts1涓嶅悓锛孲truts2瀵圭敤鎴风殑姣忎竴娆¤姹傞兘浼氬垱寤轰竴涓狝ction锛屾墍浠truts2涓殑Action鏄嚎绋嬪畨鍏ㄧ殑銆� 缁欐垜鍗拌薄鏈�娣卞埢鐨勬槸锛歴truts閰嶇疆鏂囦欢涓殑redirect瑙嗗浘鐨剈rl涓嶈兘鎺ュ彈鍙傛暟锛岃�宻truts2閰嶇疆鏂囦欢涓殑redirect瑙嗗浘鍙互鎺ュ彈鍙傛暟銆偮� 9銆乭ibernate涓殑update()鍜宻aveOrUpdate()鐨勫尯鍒紝session鐨刲oad()鍜実et()鐨勫尯鍒��10銆佺畝杩� Hibernate鍜� JDBC鐨勪紭缂虹偣?濡備綍涔﹀啓涓�涓� one to many閰嶇疆鏂囦欢.11銆乮Batis涓嶩ibernate鏈変粈涔堜笉鍚�?鐩稿悓鐐癸細灞忚斀jdbc api鐨勫簳灞傝闂粏鑺傦紝浣跨敤鎴戜滑涓嶇敤涓巎dbc api鎵撲氦閬擄紝灏卞彲浠ヨ闂暟鎹�俲dbc api缂栫▼娴佺▼鍥哄畾锛岃繕灏唖ql璇彞涓巎ava浠g爜娣锋潅鍦ㄤ簡涓�璧凤紝缁忓父闇�瑕佹嫾鍑憇ql璇彞锛岀粏鑺傚緢绻佺悙銆俰batis鐨勫ソ澶勶細灞忚斀jdbc api鐨勫簳灞傝闂粏鑺傦紱灏唖ql璇彞涓巎ava浠g爜杩涜鍒嗙;鎻愪緵浜嗗皢缁撴灉闆嗚嚜鍔ㄥ皝瑁呯О涓哄疄浣撳璞″拰瀵硅薄鐨勯泦鍚堢殑鍔熻兘锛宷ueryForList杩斿洖瀵硅薄闆嗗悎锛岀敤queryForObject杩斿洖鍗曚釜瀵硅薄锛涙彁渚涗簡鑷姩灏嗗疄浣撳璞$殑灞炴�т紶閫掔粰sql璇彞鐨勫弬鏁般�� Hibernate鏄竴涓叏鑷姩鐨刼rm鏄犲皠宸ュ叿锛屽畠鍙互鑷姩鐢熸垚sql璇彞,ibatis闇�瑕佹垜浠嚜宸卞湪xml閰嶇疆鏂囦欢涓啓sql璇彞锛宧ibernate瑕佹瘮ibatis鍔熻兘璐熻矗鍜屽己澶у緢澶氥�傚洜涓篽ibernate鑷姩鐢熸垚sql璇彞锛屾垜浠棤娉曟帶鍒惰璇彞锛屾垜浠氨鏃犳硶鍘诲啓鐗瑰畾鐨勯珮鏁堢巼鐨剆ql銆傚浜庝竴浜涗笉澶鏉傜殑sql鏌ヨ锛宧ibernate鍙互寰堝ソ甯垜浠畬鎴愶紝浣嗘槸锛屽浜庣壒鍒鏉傜殑鏌ヨ锛宧ibernate灏卞緢闅鹃�傚簲浜嗭紝杩欐椂鍊欑敤ibatis灏辨槸涓嶉敊鐨勯�夋嫨锛屽洜涓篿batis杩樻槸鐢辨垜浠嚜宸卞啓sql璇彞銆偮� 12銆佸啓Hibernate鐨勪竴瀵瑰鍜屽瀵逛竴鍙屽悜鍏宠仈鐨刼rm閰嶇疆?9銆乭ibernate鐨刬nverse灞炴�х殑浣滅敤?瑙e喅鏂规涓�锛屾寜鐓bject[]鏁版嵁鍙栧嚭鏁版嵁锛岀劧鍚庤嚜宸辩粍bean瑙e喅鏂规浜岋紝瀵规瘡涓〃鐨刡ean鍐欐瀯閫犲嚱鏁帮紝姣斿琛ㄤ竴瑕佹煡鍑篺ield1,field2涓や釜瀛楁锛岄偅涔堟湁涓�涓瀯閫犲嚱鏁板氨鏄疊ean(type1filed1,type2field2) 锛岀劧鍚庡湪hql閲岄潰灏卞彲浠ョ洿鎺ョ敓鎴愯繖涓猙ean浜嗐�� 13銆佸湪DAO涓浣曚綋鐜癉AO璁捐妯″紡?瑙e喅鏂规涓�锛屾寜鐓bject[]鏁版嵁鍙栧嚭鏁版嵁锛岀劧鍚庤嚜宸辩粍bean瑙e喅鏂规浜岋紝瀵规瘡涓〃鐨刡ean鍐欐瀯閫犲嚱鏁帮紝姣斿琛ㄤ竴瑕佹煡鍑篺ield1,field2涓や釜瀛楁锛岄偅涔堟湁涓�涓瀯閫犲嚱鏁板氨鏄疊ean(type1filed1,type2field2) 锛岀劧鍚庡湪hql閲岄潰灏卞彲浠ョ洿鎺ョ敓鎴愯繖涓猙ean浜嗐�� 14銆乻pring+Hibernate涓鎵樻柟妗堟�庝箞閰嶇疆?瑙e喅鏂规涓�锛屾寜鐓bject[]鏁版嵁鍙栧嚭鏁版嵁锛岀劧鍚庤嚜宸辩粍bean瑙e喅鏂规浜岋紝瀵规瘡涓〃鐨刡ean鍐欐瀯閫犲嚱鏁帮紝姣斿琛ㄤ竴瑕佹煡鍑篺ield1,field2涓や釜瀛楁锛岄偅涔堟湁涓�涓瀯閫犲嚱鏁板氨鏄疊ean(type1filed1,type2field2) 锛岀劧鍚庡湪hql閲岄潰灏卞彲浠ョ洿鎺ョ敓鎴愯繖涓猙ean浜嗐�� 15銆乻pring+Hibernate涓鎵樻柟妗堟�庝箞閰嶇疆?瑙e喅鏂规涓�锛屾寜鐓bject[]鏁版嵁鍙栧嚭鏁版嵁锛岀劧鍚庤嚜宸辩粍bean瑙e喅鏂规浜岋紝瀵规瘡涓〃鐨刡ean鍐欐瀯閫犲嚱鏁帮紝姣斿琛ㄤ竴瑕佹煡鍑篺ield1,field2涓や釜瀛楁锛岄偅涔堟湁涓�涓瀯閫犲嚱鏁板氨鏄疊ean(type1filed1,type2field2) 锛岀劧鍚庡湪hql閲岄潰灏卞彲浠ョ洿鎺ョ敓鎴愯繖涓猙ean浜嗐�� 16. hibernate杩涜澶氳〃鏌ヨ姣忎釜琛ㄤ腑鍚勫彇鍑犱釜瀛楁锛屼篃灏辨槸璇存煡璇㈠嚭鏉ョ殑缁撴灉闆嗘病鏈変竴涓疄浣撶被涓庝箣瀵瑰簲濡備綍瑙e喅锛� 瑙e喅鏂规涓�锛屾寜鐓bject[]鏁版嵁鍙栧嚭鏁版嵁锛岀劧鍚庤嚜宸辩粍bean瑙e喅鏂规浜岋紝瀵规瘡涓〃鐨刡ean鍐欐瀯閫犲嚱鏁帮紝姣斿琛ㄤ竴瑕佹煡鍑篺ield1,field2涓や釜瀛楁锛岄偅涔堟湁涓�涓瀯閫犲嚱鏁板氨鏄疊ean(type1filed1,type2field2) 锛岀劧鍚庡湪hql閲岄潰灏卞彲浠ョ洿鎺ョ敓鎴愯繖涓猙ean浜嗐��17.浠嬬粛涓�涓婬ibernate鐨勪簩绾х紦瀛樻寜鐓т互涓嬫�濊矾鏉ュ洖绛旓細锛�1锛夐鍏堣娓呮浠�涔堟槸缂撳瓨锛岋紙2锛夊啀璇存湁浜唄ibernate鐨凷ession灏辨槸涓�绾х紦瀛橈紝鍗虫湁浜嗕竴绾х紦瀛橈紝涓轰粈涔堣繕瑕佹湁浜岀骇缂撳瓨锛岋紙3锛夋渶鍚庡啀璇村浣曢厤缃瓾ibernate鐨勪簩绾х紦瀛樸�傦紙1锛夌紦瀛樺氨鏄妸浠ュ墠浠庢暟鎹簱涓煡璇㈠嚭鏉ュ拰浣跨敤杩囩殑瀵硅薄淇濆瓨鍦ㄥ唴瀛樹腑锛堜竴涓暟鎹粨鏋勪腑锛夛紝杩欎釜鏁版嵁缁撴瀯閫氬父鏄垨绫讳技Hashmap锛屽綋浠ュ悗瑕佷娇鐢ㄦ煇涓璞℃椂锛屽厛鏌ヨ缂撳瓨涓槸鍚︽湁杩欎釜瀵硅薄锛屽鏋滄湁鍒欎娇鐢ㄧ紦瀛樹腑鐨勫璞★紝濡傛灉娌℃湁鍒欏幓鏌ヨ鏁版嵁搴擄紝骞跺皢鏌ヨ鍑烘潵鐨勫璞′繚瀛樺湪缂撳瓨涓紝浠ヤ究涓嬫浣跨敤銆備笅闈㈡槸缂撳瓨鐨勪吉浠g爜锛氬紩鍑篽ibernate鐨勭浜岀骇缂撳瓨锛岀敤涓嬮潰鐨勪吉浠g爜鍒嗘瀽浜咰ache鐨勫疄鐜板師鐞咲ao{聽 聽 聽 hashmap map = newmap();聽 聽 聽 User getUser(integerid)聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 User user =map.get(id)聽 聽 聽 聽 聽 聽 聽 if(user ==null)聽 聽 聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 user =session.get(id);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 map.put(id,user);聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 return user;聽 聽 聽 }} Dao{聽 聽 聽 Cache cache = null聽 聽 聽 setCache(Cachecache)聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 this.cache =cache聽 聽 聽 }聽 聽 聽 聽 聽 聽 User getUser(int id)聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 if(cache!=null)聽 聽 聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Useruser = cache.get(id);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 if(user==null)聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 {聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 user= session.get(id);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 cache.put(id,user);聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 returnuser;聽 聽 聽 聽 聽 聽 聽 }聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 returnsession.get(id);聽 聽 聽 }}锛�2锛塇ibernate鐨凷ession灏辨槸涓�绉嶇紦瀛橈紝鎴戜滑閫氬父灏嗕箣绉颁负Hibernate鐨勪竴绾х紦瀛橈紝褰撴兂浣跨敤session浠庢暟鎹簱涓煡璇㈠嚭涓�涓璞℃椂锛孲ession涔熸槸鍏堜粠鑷繁鍐呴儴鏌ョ湅鏄惁瀛樺湪杩欎釜瀵硅薄锛屽瓨鍦ㄥ垯鐩存帴杩斿洖锛屼笉瀛樺湪鎵嶅幓璁块棶鏁版嵁搴擄紝骞跺皢鏌ヨ鐨勭粨鏋滀繚瀛樺湪鑷繁鍐呴儴銆傜敱浜嶴ession浠h〃涓�娆′細璇濊繃绋嬶紝涓�涓猄ession涓庝竴涓暟鎹簱杩炴帴鐩稿叧杩烇紝鎵�浠ession鏈�濂戒笉瑕侀暱鏃堕棿淇濇寔鎵撳紑锛岄�氬父浠呯敤浜庝竴涓簨鍔″綋涓紝鍦ㄤ簨鍔$粨鏉熸椂灏卞簲鍏抽棴銆傚苟涓擲ession鏄嚎绋嬩笉瀹夊叏鐨勶紝琚涓嚎绋嬪叡浜椂瀹规槗鍑虹幇闂銆傞�氬父鍙湁閭g鍏ㄥ眬鎰忎箟涓婄殑缂撳瓨鎵嶆槸鐪熸鐨勭紦瀛樺簲鐢紝鎵嶆湁杈冨ぇ鐨勭紦瀛樹环鍊硷紝鍥犳锛孒ibernate鐨凷ession杩欎竴绾х紦瀛樼殑缂撳瓨浣滅敤骞朵笉鏄庢樉锛屽簲鐢ㄤ环鍊间笉澶с�侶ibernate鐨勪簩绾х紦瀛樺氨鏄涓篐ibernate閰嶇疆涓�绉嶅叏灞�缂撳瓨锛岃澶氫釜绾跨▼鍜屽涓簨鍔¢兘鍙互鍏变韩杩欎釜缂撳瓨銆傛垜浠笇鏈涚殑鏄竴涓汉浣跨敤杩囷紝鍏朵粬浜轰篃鍙互浣跨敤锛宻ession娌℃湁杩欑鏁堟灉銆傦紙3锛変簩绾х紦瀛樻槸鐙珛浜嶩ibernate鐨勮蒋浠堕儴浠讹紝灞炰簬绗笁鏂圭殑浜у搧锛屽涓巶鍟嗗拰缁勭粐閮芥彁渚涙湁缂撳瓨浜у搧锛屼緥濡傦紝EHCache鍜孫SCache绛夌瓑銆傚湪Hibernate涓娇鐢ㄤ簩绾х紦瀛橈紝棣栧厛灏辫鍦╤ibernate.cfg.xml閰嶇疆鏂囦欢涓厤缃娇鐢ㄥ摢涓巶瀹剁殑缂撳瓨浜у搧锛屾帴鐫�闇�瑕侀厤缃缂撳瓨浜у搧鑷繁鐨勯厤缃枃浠讹紝鏈�鍚庤閰嶇疆Hibernate涓殑鍝簺瀹炰綋瀵硅薄瑕佺撼鍏ュ埌浜岀骇缂撳瓨鐨勭鐞嗕腑銆傛槑鐧戒簡浜岀骇缂撳瓨鍘熺悊鍜屾湁浜嗚繖涓�濊矾鍚庯紝寰堝鏄撻厤缃捣Hibernate鐨勪簩绾х紦瀛樸�傛墿灞曠煡璇嗭細涓�涓猄essionFactory鍙互鍏宠仈涓�涓簩绾х紦瀛橈紝涔熷嵆涓�涓簩绾х紦瀛樺彧鑳借礋璐g紦瀛樹竴涓暟鎹簱涓殑鏁版嵁锛屽綋浣跨敤Hibernate鐨勪簩绾х紦瀛樺悗锛屾敞鎰忎笉瑕佹湁鍏朵粬鐨勫簲鐢ㄦ垨SessionFactory鏉ユ洿鏀瑰綋鍓嶆暟鎹簱涓殑鏁版嵁锛岃繖鏍风紦瀛樼殑鏁版嵁灏变細涓庢暟鎹簱涓殑瀹為檯鏁版嵁涓嶄竴鑷淬�� 18銆丼pring鐨勪緷璧栨敞鍏ユ槸浠�涔堟剰鎬�?缁欎竴涓� Bean 鐨� message灞炴��,瀛楃涓茬被鍨�,娉ㄥ叆鍊间负"Hello"鐨� XML閰嶇疆鏂囦欢璇ユ�庝箞鍐�? 19銆丣do鏄粈涔�?JDO鏄疛ava瀵硅薄鎸佷箙鍖栫殑鏂扮殑瑙勮寖锛屼负java data object鐨勭畝绉�,涔熸槸涓�涓敤浜庡瓨鍙栨煇绉嶆暟鎹粨搴撲腑鐨勫璞$殑鏍囧噯鍖朅PI銆侸DO鎻愪緵浜嗛�忔槑鐨勫璞″瓨鍌紝鍥犳瀵瑰紑鍙戜汉鍛樻潵璇达紝瀛樺偍鏁版嵁瀵硅薄瀹屽叏涓嶉渶瑕侀澶栫殑浠g爜锛堝JDBC API鐨勪娇鐢級銆傝繖浜涚箒鐞愮殑渚嬭宸ヤ綔宸茬粡杞Щ鍒癑DO浜у搧鎻愪緵鍟嗚韩涓婏紝浣垮紑鍙戜汉鍛樿В鑴卞嚭鏉ワ紝浠庤�岄泦涓椂闂村拰绮惧姏鍦ㄤ笟鍔¢�昏緫涓娿�傚彟澶栵紝JDO寰堢伒娲伙紝鍥犱负瀹冨彲浠ュ湪浠讳綍鏁版嵁搴曞眰涓婅繍琛屻�侸DBC鍙槸闈㈠悜鍏崇郴鏁版嵁搴擄紙RDBMS锛塉DO鏇撮�氱敤锛屾彁渚涘埌浠讳綍鏁版嵁搴曞眰鐨勫瓨鍌ㄥ姛鑳斤紝姣斿鍏崇郴鏁版嵁搴撱�佹枃浠躲�乆ML浠ュ強瀵硅薄鏁版嵁搴擄紙ODBMS锛夌瓑绛夛紝浣垮緱搴旂敤鍙Щ妞嶆�ф洿寮恒�� 20銆佷粈涔堟槸spring鐨処OC AOP21銆丼TRUTS鐨勫伐浣滄祦绋嬶紒22銆乻pring涓嶦JB鐨勫尯鍒紒锛� 鍏�.杞欢宸ョ▼涓庤璁℃ā寮�1銆乁ML鏂归潰鏍囧噯寤烘ā璇█UML銆傜敤渚嬪浘,闈欐�佸浘(鍖呮嫭绫诲浘銆佸璞″浘鍜屽寘鍥�),琛屼负鍥�,浜や簰鍥�(椤哄簭鍥�,鍚堜綔鍥�),瀹炵幇鍥俱��2銆乯2ee甯哥敤鐨勮璁℃ā寮忥紵璇存槑宸ュ巶妯″紡銆傛�诲叡23绉嶏紝鍒嗕负涓夊ぇ绫伙細鍒涘缓鍨嬶紝缁撴瀯鍨嬶紝琛屼负鍨嬫垜鍙寰楀叾涓父鐢ㄧ殑6銆�7绉嶏紝鍒嗗埆鏄細鍒涘缓鍨嬶紙宸ュ巶銆佸伐鍘傛柟娉曘�佹娊璞″伐鍘傘�佸崟渚嬶級缁撴瀯鍨嬶紙鍖呰銆侀�傞厤鍣紝缁勫悎锛屼唬鐞嗭級琛屼负锛堣瀵熻�咃紝妯$増锛岀瓥鐣ワ級鐒跺悗鍐嶉拡瀵逛綘鐔熸倝鐨勬ā寮忚皥璋堜綘鐨勭悊瑙e嵆鍙�偮� Java涓殑23绉嶈璁℃ā寮忥細Factory锛堝伐鍘傛ā寮忥級锛屄� 聽 Builder锛堝缓閫犳ā寮忥級锛屄� 聽 聽 Factory Method锛堝伐鍘傛柟娉曟ā寮忥級锛孭rototype锛堝師濮嬫ā鍨嬫ā寮忥級锛孲ingleton锛堝崟渚嬫ā寮忥級锛屄� Facade锛堥棬闈㈡ā寮忥級锛孉dapter锛堥�傞厤鍣ㄦā寮忥級锛屄� Bridge锛堟ˉ姊佹ā寮忥級锛屄� 聽 聽 Composite锛堝悎鎴愭ā寮忥級锛孌ecorator锛堣楗版ā寮忥級锛屄� Flyweight锛堜韩鍏冩ā寮忥級锛屄� 聽 Proxy锛堜唬鐞嗘ā寮忥級锛孋ommand锛堝懡浠ゆā寮忥級锛屄� 聽 Interpreter锛堣В閲婂櫒妯″紡锛夛紝 Visitor锛堣闂�呮ā寮忥級锛孖terator锛堣凯浠e瓙妯″紡锛夛紝聽 Mediator锛堣皟鍋滆�呮ā寮忥級锛屄� Memento锛堝蹇樺綍妯″紡锛夛紝Observer锛堣瀵熻�呮ā寮忥級锛屄� State锛堢姸鎬佹ā寮忥級锛屄� 聽 聽 聽 Strategy锛堢瓥鐣ユā寮忥級锛孴emplate Method锛堟ā鏉挎柟娉曟ā寮忥級锛� Chain Of Responsibleity锛堣矗浠婚摼妯″紡锛夊伐鍘傛ā寮忥細宸ュ巶妯″紡鏄竴绉嶇粡甯歌浣跨敤鍒扮殑妯″紡锛屾牴鎹伐鍘傛ā寮忓疄鐜扮殑绫诲彲浠ユ牴鎹彁渚涚殑鏁版嵁鐢熸垚涓�缁勭被涓煇涓�涓被鐨勫疄渚嬶紝閫氬父杩欎竴缁勭被鏈変竴涓叕鍏辩殑鎶借薄鐖剁被骞朵笖瀹炵幇浜嗙浉鍚岀殑鏂规硶锛屼絾鏄繖浜涙柟娉曢拡瀵逛笉鍚岀殑鏁版嵁杩涜浜嗕笉鍚岀殑鎿嶄綔銆傞鍏堥渶瑕佸畾涔変竴涓熀绫伙紝璇ョ被鐨勫瓙绫婚�氳繃涓嶅悓鐨勬柟娉曞疄鐜颁簡鍩虹被涓殑鏂规硶銆傜劧鍚庨渶瑕佸畾涔変竴涓伐鍘傜被锛屽伐鍘傜被鍙互鏍规嵁鏉′欢鐢熸垚涓嶅悓鐨勫瓙绫诲疄渚嬨�傚綋寰楀埌瀛愮被鐨勫疄渚嬪悗锛屽紑鍙戜汉鍛樺彲浠ヨ皟鐢ㄥ熀绫讳腑鐨勬柟娉曡�屼笉蹇呰�冭檻鍒板簳杩斿洖鐨勬槸鍝竴涓瓙绫荤殑瀹炰緥銆�3銆佸紑鍙戜腑閮界敤鍒颁簡閭d簺璁捐妯″紡?鐢ㄥ湪浠�涔堝満鍚�?姣忎釜妯″紡閮芥弿杩颁簡涓�涓湪鎴戜滑鐨勭幆澧冧腑涓嶆柇鍑虹幇鐨勯棶棰橈紝鐒跺悗鎻忚堪浜嗚闂鐨勮В鍐虫柟妗堢殑鏍稿績銆傞�氳繃杩欑鏂瑰紡锛屼綘鍙互鏃犳暟娆″湴浣跨敤閭d簺宸叉湁鐨勮В鍐虫柟妗堬紝鏃犻渶鍦ㄩ噸澶嶇浉鍚岀殑宸ヤ綔銆備富瑕佺敤鍒颁簡MVC鐨勮璁℃ā寮忋�傜敤鏉ュ紑鍙慗SP/Servlet鎴栬�匤2EE鐨勭浉鍏冲簲鐢ㄣ�傜畝鍗曞伐鍘傛ā寮忕瓑銆備節. j2ee閮ㄥ垎1銆丅S涓嶤S鐨勮仈绯讳笌鍖哄埆銆侰/S鏄疌lient/Server鐨勭缉鍐欍�傛湇鍔″櫒閫氬父閲囩敤楂樻�ц兘鐨凱C銆佸伐浣滅珯鎴栧皬鍨嬫満锛屽苟閲囩敤澶у瀷鏁版嵁搴撶郴缁燂紝濡侽racle銆丼ybase銆両nFORMix鎴� SQL Server銆傚鎴风闇�瑕佸畨瑁呬笓鐢ㄧ殑瀹㈡埛绔蒋浠躲�侭/锛虫槸Brower/Server鐨勭缉鍐欙紝瀹㈡埛鏈轰笂鍙瀹夎涓�涓祻瑙堝櫒锛圔rowser锛夛紝濡侼etscape Navigator鎴朓nternet Explorer锛屾湇鍔″櫒瀹夎Oracle銆丼ybase銆両nFORMix鎴� SQL Server绛夋暟鎹簱銆傚湪杩欑缁撴瀯涓嬶紝鐢ㄦ埛鐣岄潰瀹屽叏閫氳繃WWW娴忚鍣ㄥ疄鐜帮紝涓�閮ㄥ垎浜嬪姟閫昏緫鍦ㄥ墠绔疄鐜帮紝浣嗘槸涓昏浜嬪姟閫昏緫鍦ㄦ湇鍔″櫒绔疄鐜般�傛祻瑙堝櫒閫氳繃锛積b Server鍚屾暟鎹簱杩涜鏁版嵁浜や簰銆侰/S 涓� B/S鍖哄埆锛氾紤锛庣‖浠剁幆澧冧笉鍚�:C/S 涓�鑸缓绔嬪湪涓撶敤鐨勭綉缁滀笂,灏忚寖鍥撮噷鐨勭綉缁滅幆澧�,灞�鍩熺綉涔嬮棿鍐嶉�氳繃涓撻棬鏈嶅姟鍣ㄦ彁渚涜繛鎺ュ拰鏁版嵁浜ゆ崲鏈嶅姟.B/S 寤虹珛鍦ㄥ箍鍩熺綉涔嬩笂鐨�,涓嶅繀鏄笓闂ㄧ殑缃戠粶纭欢鐜,渚嬩笌鐢佃瘽涓婄綉,绉熺敤璁惧.淇℃伅鑷繁绠$悊.鏈夋瘮C/S鏇村己鐨勯�傚簲鑼冨洿,涓�鑸彧瑕佹湁鎿嶄綔绯荤粺鍜屾祻瑙堝櫒灏辫锛掞紟瀵瑰畨鍏ㄨ姹備笉鍚孋/S 涓�鑸潰鍚戠浉瀵瑰浐瀹氱殑鐢ㄦ埛缇�,瀵逛俊鎭畨鍏ㄧ殑鎺у埗鑳藉姏寰堝己.涓�鑸珮搴︽満瀵嗙殑淇℃伅绯荤粺閲囩敤C/S缁撴瀯閫傚疁.鍙互閫氳繃B/S鍙戝竷閮ㄥ垎鍙叕寮�淇℃伅.B/S 寤虹珛鍦ㄥ箍鍩熺綉涔嬩笂,瀵瑰畨鍏ㄧ殑鎺у埗鑳藉姏鐩稿寮�,鍙兘闈㈠悜涓嶅彲鐭ョ殑鐢ㄦ埛銆傦紦锛庡绋嬪簭鏋舵瀯涓嶅悓C/S 绋嬪簭鍙互鏇村姞娉ㄩ噸娴佺▼,鍙互瀵规潈闄愬灞傛鏍¢獙,瀵圭郴缁熻繍琛岄�熷害鍙互杈冨皯鑰冭檻.B/S 瀵瑰畨鍏ㄤ互鍙婅闂�熷害鐨勫閲嶇殑鑰冭檻,寤虹珛鍦ㄩ渶瑕佹洿鍔犱紭鍖栫殑鍩虹涔嬩笂.姣擟/S鏈夋洿楂樼殑瑕佹眰 B/S缁撴瀯鐨勭▼搴忔灦鏋勬槸鍙戝睍鐨勮秼鍔�,浠嶮S鐨�.Net绯诲垪鐨凚izTalk 2000Exchange 2000绛�,鍏ㄩ潰鏀寔缃戠粶鐨勬瀯浠舵惌寤虹殑绯荤粺. SUN鍜孖BM鎺ㄧ殑JavaBean鏋勪欢鎶�鏈瓑,浣� B/S鏇村姞鎴愮啛.锛旓紟杞欢閲嶇敤涓嶅悓C/S 绋嬪簭鍙互涓嶅彲閬垮厤鐨勬暣浣撴�ц�冭檻,鏋勪欢鐨勯噸鐢ㄦ�т笉濡傚湪B/S瑕佹眰涓嬬殑鏋勪欢鐨勯噸鐢ㄦ�уソ.B/S 瀵圭殑澶氶噸缁撴瀯,瑕佹眰鏋勪欢鐩稿鐙珛鐨勫姛鑳�.鑳藉鐩稿杈冨ソ鐨勯噸鐢�.灏卞叆涔版潵鐨勯妗屽彲浠ュ啀鍒╃敤,鑰屼笉鏄仛鍦ㄥ涓婄殑鐭冲ご妗屽瓙锛曪紟绯荤粺缁存姢涓嶅悓聽 C/S 绋嬪簭鐢变簬鏁翠綋鎬�,蹇呴』鏁翠綋鑰冨療,澶勭悊鍑虹幇鐨勯棶棰樹互鍙婄郴缁熷崌绾�.鍗囩骇闅�.鍙兘鏄啀鍋氫竴涓叏鏂扮殑绯荤粺B/S 鏋勪欢缁勬垚,鏂归潰鏋勪欢涓埆鐨勬洿鎹�,瀹炵幇绯荤粺鐨勬棤缂濆崌绾�.绯荤粺缁存姢寮�閿�鍑忓埌鏈�灏�.鐢ㄦ埛浠庣綉涓婅嚜宸变笅杞藉畨瑁呭氨鍙互瀹炵幇鍗囩骇.锛栵紟澶勭悊闂涓嶅悓C/S 绋嬪簭鍙互澶勭悊鐢ㄦ埛闈㈠浐瀹�,骞朵笖鍦ㄧ浉鍚屽尯鍩�,瀹夊叏瑕佹眰楂橀渶姹�,涓庢搷浣滅郴缁熺浉鍏�.搴旇閮芥槸鐩稿悓鐨勭郴缁烞/S 寤虹珛鍦ㄥ箍鍩熺綉涓�,闈㈠悜涓嶅悓鐨勭敤鎴风兢,鍒嗘暎鍦板煙,杩欐槸C/S鏃犳硶浣滃埌鐨�.涓庢搷浣滅郴缁熷钩鍙板叧绯绘渶灏�.锛楋紟鐢ㄦ埛鎺ュ彛涓嶅悓C/S 澶氭槸寤虹珛鐨刉indow骞冲彴涓�,琛ㄧ幇鏂规硶鏈夐檺,瀵圭▼搴忓憳鏅亶瑕佹眰杈冮珮B/S 寤虹珛鍦ㄦ祻瑙堝櫒涓�,鏈夋洿鍔犱赴瀵屽拰鐢熷姩鐨勮〃鐜版柟寮忎笌鐢ㄦ埛浜ゆ祦.骞朵笖澶ч儴鍒嗛毦搴﹀噺浣�,鍑忎綆寮�鍙戞垚鏈�.锛橈紟淇℃伅娴佷笉鍚孋/S 绋嬪簭涓�鑸槸鍏稿瀷鐨勪腑澶泦鏉冪殑鏈烘寮忓鐞�,浜や簰鎬х浉瀵逛綆B/S 淇℃伅娴佸悜鍙彉鍖�, B-B B-C B-G绛変俊鎭�佹祦鍚戠殑鍙樺寲,鏇村儚浜ゆ槗涓績銆�2銆佸簲鐢ㄦ湇鍔″櫒涓嶹EB SERVER鐨勫尯鍒紵搴旂敤鏈嶅姟鍣細Weblogic銆乀omcat銆丣bossWEB SERVER锛欼IS銆� Apache3銆佸簲鐢ㄦ湇鍔″櫒鏈夐偅浜涳紵BEA WebLogic Server锛孖BM WebSphere Application Server锛孫racle9i ApplicationServer锛宩Boss锛孴omcat 4銆丣2EE鏄粈涔堬紵绛�:Je22鏄疭un鍏徃鎻愬嚭鐨勫灞�(multi-diered),鍒嗗竷寮�(distributed),鍩轰簬缁勪欢(component-base)鐨勪紒涓氱骇搴旂敤妯″瀷(enterpriese applicationmodel).鍦ㄨ繖鏍风殑涓�涓簲鐢ㄧ郴缁熶腑锛屽彲鎸夌収鍔熻兘鍒掑垎涓轰笉鍚岀殑缁勪欢锛岃繖浜涚粍浠跺張鍙湪涓嶅悓璁$畻鏈轰笂锛屽苟涓斿浜庣浉搴旂殑灞傛(tier)涓�傛墍灞炲眰娆″寘鎷鎴峰眰(clietn tier)缁勪欢,web灞傚拰缁勪欢,Business灞傚拰缁勪欢,浼佷笟淇℃伅绯荤粺(EIS)灞傘�� 涓�涓彟绫荤殑鍥炵瓟锛歫2ee灏辨槸澧炲垹鏀规煡銆�5銆丣2EE鏄妧鏈繕鏄钩鍙拌繕鏄鏋讹紵浠�涔堟槸J2EE聽 J2EE鏈韩鏄竴涓爣鍑嗭紝涓�涓负浼佷笟鍒嗗竷寮忓簲鐢ㄧ殑寮�鍙戞彁渚涚殑鏍囧噯骞冲彴銆偮� J2EE涔熸槸涓�涓鏋讹紝鍖呮嫭JDBC銆丣NDI銆丷MI銆丣MS銆丒JB銆丣TA绛夋妧鏈��6銆佽瀵逛互涓嬪湪J2EE涓父鐢ㄧ殑鍚嶈瘝杩涜瑙i噴(鎴栫畝鍗曟弿杩�)web瀹瑰櫒锛氱粰澶勪簬鍏朵腑鐨勫簲鐢ㄧ▼搴忕粍浠讹紙JSP锛孲ERVLET锛夋彁渚涗竴涓幆澧冿紝浣縅SP,SERVLET鐩存帴鏇村鍣ㄤ腑鐨勭幆澧冨彉閲忔帴鍙d氦浜掞紝涓嶅繀鍏虫敞鍏跺畠绯荤粺闂銆備富瑕佹湁WEB鏈嶅姟鍣ㄦ潵瀹炵幇銆備緥濡傦細TOMCAT,WEBLOGIC,WEBSPHERE绛夈�傝瀹瑰櫒鎻愪緵鐨勬帴鍙d弗鏍奸伒瀹圝2EE瑙勮寖涓殑WEB APPLICATION 鏍囧噯銆傛垜浠妸閬靛畧浠ヤ笂鏍囧噯鐨刉EB鏈嶅姟鍣ㄥ氨鍙仛J2EE涓殑WEB瀹瑰櫒銆侲JB瀹瑰櫒锛欵nterprise java bean瀹瑰櫒銆傛洿鍏锋湁琛屼笟棰嗗煙鐗硅壊銆備粬鎻愪緵缁欒繍琛屽湪鍏朵腑鐨勭粍浠禘JB鍚勭绠$悊鍔熻兘銆傚彧瑕佹弧瓒矹2EE瑙勮寖鐨凟JB鏀惧叆璇ュ鍣紝椹笂灏变細琚鍣ㄨ繘琛岄珮鏁堢巼鐨勭鐞嗐�傚苟涓斿彲浠ラ�氳繃鐜版垚鐨勬帴鍙f潵鑾峰緱绯荤粺绾у埆鐨勬湇鍔°�備緥濡傞偖浠舵湇鍔°�佷簨鍔$鐞嗐�侸NDI锛氾紙Java Naming & Directory Interface锛塉AVA鍛藉悕鐩綍鏈嶅姟銆備富瑕佹彁渚涚殑鍔熻兘鏄細鎻愪緵涓�涓洰褰曠郴缁燂紝璁╁叾瀹冨悇鍦扮殑搴旂敤绋嬪簭鍦ㄥ叾涓婇潰鐣欎笅鑷繁鐨勭储寮曪紝浠庤�屾弧瓒冲揩閫熸煡鎵惧拰瀹氫綅鍒嗗竷寮忓簲鐢ㄧ▼搴忕殑鍔熻兘銆侸MS锛氾紙Java Message Service锛塉AVA娑堟伅鏈嶅姟銆備富瑕佸疄鐜板悇涓簲鐢ㄧ▼搴忎箣闂寸殑閫氳銆傚寘鎷偣瀵圭偣鍜屽箍鎾�侸TA锛氾紙Java Transaction API锛塉AVA浜嬪姟鏈嶅姟銆傛彁渚涘悇绉嶅垎甯冨紡浜嬪姟鏈嶅姟銆傚簲鐢ㄧ▼搴忓彧闇�璋冪敤鍏舵彁渚涚殑鎺ュ彛鍗冲彲銆侸AF锛氾紙Java Action FrameWork锛塉AVA瀹夊叏璁よ瘉妗嗘灦銆傛彁渚涗竴浜涘畨鍏ㄦ帶鍒舵柟闈㈢殑妗嗘灦銆傝寮�鍙戣�呴�氳繃鍚勭閮ㄧ讲鍜岃嚜瀹氫箟瀹炵幇鑷繁鐨勪釜鎬у畨鍏ㄦ帶鍒剁瓥鐣ャ�俁MI/IIOP:锛圧emote Method Invocation /internet瀵硅薄璇锋眰涓粙鍗忚锛変粬浠富瑕佺敤浜庨�氳繃杩滅▼璋冪敤鏈嶅姟銆備緥濡傦紝杩滅▼鏈変竴鍙拌绠楁満涓婅繍琛屼竴涓▼搴忥紝瀹冩彁渚涜偂绁ㄥ垎鏋愭湇鍔★紝鎴戜滑鍙互鍦ㄦ湰鍦拌绠楁満涓婂疄鐜板鍏剁洿鎺ヨ皟鐢ㄣ�傚綋鐒惰繖鏄閫氳繃涓�瀹氱殑瑙勮寖鎵嶈兘鍦ㄥ紓鏋勭殑绯荤粺涔嬮棿杩涜閫氫俊銆俁MI鏄疛AVA鐗规湁鐨勩��7銆佸浣曠粰weblogic鎸囧畾澶у皬鐨勫唴瀛�?锛堣繖涓棶棰樹笉浣滃叿浣撳洖绛旓紝鍒楀嚭鏉ュ彧鏄憡璇夎鑰呭彲鑳戒細閬囧埌浠�涔堥棶棰橈紝浣犱笉闇�瑕侀潰闈勘鍒帮紝浠�涔堥兘绮鹃�氥�傦級 鍦ㄥ惎鍔╓eblogic鐨勮剼鏈腑锛堜綅浜庢墍鍦―omian瀵瑰簲鏈嶅姟鍣ㄧ洰褰曚笅鐨剆tartServerName锛夛紝澧炲姞set MEM_ARGS=-Xms32m-Xmx200m锛屽彲浠ヨ皟鏁存渶灏忓唴瀛樹负32M锛屾渶澶�200M8銆佸浣曡瀹氱殑weblogic鐨勭儹鍚姩妯″紡(寮�鍙戞ā寮�)涓庝骇鍝佸彂甯冩ā寮�?鍙互鍦ㄧ鐞嗘帶鍒跺彴涓慨鏀瑰搴旀湇鍔″櫒鐨勫惎鍔ㄦā寮忎负寮�鍙戞垨浜у搧妯″紡涔嬩竴銆傛垨鑰呬慨鏀规湇鍔$殑鍚姩鏂囦欢鎴栬�卌ommenv鏂囦欢锛屽鍔爏etPRODUCTION_MODE=true銆�9銆佸浣曞惎鍔ㄦ椂涓嶉渶杈撳叆鐢ㄦ埛鍚嶄笌瀵嗙爜?淇敼鏈嶅姟鍚姩鏂囦欢锛屽鍔� WLS_USER鍜學LS_PW椤广�備篃鍙互鍦╞oot.properties鏂囦欢涓鍔犲姞瀵嗚繃鐨勭敤鎴峰悕鍜屽瘑鐮�.10銆佸湪weblogic绠$悊鍒跺彴涓涓�涓簲鐢ㄥ煙(鎴栬�呰鏄竴涓綉绔�,Domain)杩涜jms鍙奺jb鎴栬繛鎺ユ睜绛夌浉鍏充俊鎭繘琛岄厤缃悗,瀹為檯淇濆瓨鍦ㄤ粈涔堟枃浠朵腑?淇濆瓨鍦ㄦDomain鐨刢onfig.xml鏂囦欢涓紝瀹冩槸鏈嶅姟鍣ㄧ殑鏍稿績閰嶇疆鏂囦欢銆�11銆佽璇磜eblogic涓竴涓狣omain鐨勭己鐪佺洰褰曠粨鏋�?姣斿瑕佸皢涓�涓畝鍗曠殑helloWorld.jsp鏀惧叆浣曠洰褰曚笅,鐒剁殑鍦ㄦ祻瑙堝櫒涓婂氨鍙墦鍏ttp://涓绘満:绔彛鍙�//helloword.jsp灏卞彲浠ョ湅鍒拌繍琛岀粨鏋滀簡?鍙堟瘮濡傝繖鍏朵腑鐢ㄥ埌浜嗕竴涓嚜宸卞啓鐨刯avaBean璇ュ浣曞姙?Domain鐩綍鏈嶅姟鍣ㄧ洰褰昦pplications锛屽皢搴旂敤鐩綍鏀惧湪姝ょ洰褰曚笅灏嗗彲浠ヤ綔涓哄簲鐢ㄨ闂紝濡傛灉鏄疻eb搴旂敤锛屽簲鐢ㄧ洰褰曢渶瑕佹弧瓒砏eb搴旂敤鐩綍瑕佹眰锛宩sp鏂囦欢鍙互鐩存帴鏀惧湪搴旂敤鐩綍涓紝Javabean闇�瑕佹斁鍦ㄥ簲鐢ㄧ洰褰曠殑WEB-INF鐩綍鐨刢lasses鐩綍涓紝璁剧疆鏈嶅姟鍣ㄧ殑缂虹渷搴旂敤灏嗗彲浠ュ疄鐜板湪娴忚鍣ㄤ笂鏃犻渶杈撳叆搴旂敤鍚嶃��12銆佸湪weblogic涓彂甯僥jb闇�娑夊強鍒板摢浜涢厤缃枃浠朵笉鍚岀被鍨嬬殑EJB娑夊強鐨勯厤缃枃浠朵笉鍚岋紝閮芥秹鍙婂埌鐨勯厤缃枃浠跺寘鎷琫jb-jar.xml,weblogic-ejb-jar.xmlCMP瀹炰綋Bean涓�鑸繕闇�瑕亀eblogic-cmp-rdbms-jar.xml13銆佸浣曞湪weblogic涓繘琛宻sl閰嶇疆涓庡鎴风鐨勮璇侀厤缃垨璇磋j2ee(鏍囧噯)杩涜ssl鐨勯厤缃�?缂虹渷瀹夎涓娇鐢―emoIdentity.jks鍜孌emoTrust.jks KeyStore瀹炵幇SSL锛岄渶瑕侀厤缃湇鍔″櫒浣跨敤Enable SSL锛岄厤缃叾绔彛锛屽湪浜у搧妯″紡涓嬮渶瑕佷粠CA鑾峰彇绉佹湁瀵嗛挜鍜屾暟瀛楄瘉涔︼紝鍒涘缓identity鍜宼rust keystore锛岃杞借幏寰楃殑瀵嗛挜鍜屾暟瀛楄瘉涔︺�傚彲浠ラ厤缃SSL杩炴帴鏄崟鍚戣繕鏄弻鍚戠殑銆�14銆佸浣曟煡鐪嬪湪weblogic涓凡缁忓彂甯冪殑EJB?鍙互浣跨敤绠$悊鎺у埗鍙帮紝鍦ㄥ畠鐨凞eployment涓彲浠ユ煡鐪嬫墍鏈夊凡鍙戝竷鐨凟JB鍗�. EBJ閮ㄥ垎1銆丒JB鏄熀浜庡摢浜涙妧鏈疄鐜扮殑锛熷苟璇村嚭SessionBean鍜孍ntityBean鐨勫尯鍒紝StatefulBean鍜孲tatelessBean鐨勫尯鍒�偮� EJB鍖呮嫭Session Bean銆丒ntity Bean銆丮essage Driven Bean锛屽熀浜嶫NDI銆丷MI銆丣AT绛夋妧鏈疄鐜般�係essionBean鍦↗2EE搴旂敤绋嬪簭涓鐢ㄦ潵瀹屾垚涓�浜涙湇鍔″櫒绔殑涓氬姟鎿嶄綔锛屼緥濡傝闂暟鎹簱銆佽皟鐢ㄥ叾浠朎JB缁勪欢銆侲ntityBean琚敤鏉ヤ唬琛ㄥ簲鐢ㄧ郴缁熶腑鐢ㄥ埌鐨勬暟鎹�傚浜庡鎴锋満锛孲essionBean鏄竴绉嶉潪鎸佷箙鎬у璞★紝瀹冨疄鐜版煇浜涘湪鏈嶅姟鍣ㄤ笂杩愯鐨勪笟鍔¢�昏緫銆傚浜庡鎴锋満锛孍ntityBean鏄竴绉嶆寔涔呮�у璞★紝瀹冧唬琛ㄤ竴涓瓨鍌ㄥ湪鎸佷箙鎬у瓨鍌ㄥ櫒涓殑瀹炰綋鐨勫璞¤鍥撅紝鎴栨槸涓�涓敱鐜版湁浼佷笟搴旂敤绋嬪簭瀹炵幇鐨勫疄浣撱�係ession Bean 杩樺彲浠ュ啀缁嗗垎涓� Stateful Session Bean涓� Stateless SessionBean锛岃繖涓ょ鐨� Session Bean閮藉彲浠ュ皢绯荤粺閫昏緫鏀惧湪 method涔嬩腑鎵ц锛屼笉鍚岀殑鏄� Stateful SessionBean鍙互璁板綍鍛煎彨鑰呯殑鐘舵�侊紝鍥犳閫氬父鏉ヨ锛屼竴涓娇鐢ㄨ�呬細鏈変竴涓浉瀵瑰簲鐨� Stateful SessionBean鐨勫疄浣撱�係tateless SessionBean铏界劧涔熸槸閫昏緫缁勪欢锛屼絾鏄粬鍗翠笉璐熻矗璁板綍浣跨敤鑰呯姸鎬侊紝涔熷氨鏄褰撲娇鐢ㄨ�呭懠鍙� Stateless SessionBean鐨勬椂鍊欙紝EJB Container骞朵笉浼氭壘瀵荤壒瀹氱殑 Stateless SessionBean鐨勫疄浣撴潵鎵ц杩欎釜 method銆傛崲瑷�涔嬶紝寰堝彲鑳芥暟涓娇鐢ㄨ�呭湪鎵ц鏌愪釜 Stateless SessionBean鐨� methods鏃讹紝浼氭槸鍚屼竴涓� Bean鐨� Instance鍦ㄦ墽琛屻�備粠鍐呭瓨鏂归潰鏉ョ湅锛� Stateful SessionBean涓嶴tateless SessionBean姣旇緝锛� Stateful SessionBean浼氭秷鑰� J2EE Server杈冨鐨勫唴瀛橈紝鐒惰�� Stateful SessionBean鐨勪紭鍔垮嵈鍦ㄤ簬浠栧彲浠ョ淮鎸佷娇鐢ㄨ�呯殑鐘舵�併�� 2銆佺畝瑕佽涓�涓� EJB鐨� 7涓� Transaction Level?3銆丒JB涓嶫AVA BEAN鐨勫尯鍒紵Java Bean 鏄彲澶嶇敤鐨勭粍浠讹紝瀵笿ava Bean骞舵病鏈変弗鏍肩殑瑙勮寖锛岀悊璁轰笂璁诧紝浠讳綍涓�涓狫ava绫婚兘鍙互鏄竴涓狟ean銆備絾閫氬父鎯呭喌涓嬶紝鐢变簬Java Bean鏄瀹瑰櫒鎵�鍒涘缓锛堝Tomcat锛夌殑锛屾墍浠ava Bean搴斿叿鏈変竴涓棤鍙傜殑鏋勯�犲櫒锛屽彟澶栵紝閫氬父Java Bean杩樿瀹炵幇Serializable鎺ュ彛鐢ㄤ簬瀹炵幇Bean鐨勬寔涔呮�с�侸ava Bean瀹為檯涓婄浉褰撲簬寰蒋COM妯″瀷涓殑鏈湴杩涚▼鍐匔OM缁勪欢锛屽畠鏄笉鑳借璺ㄨ繘绋嬭闂殑銆侲nterprise Java Bean鐩稿綋浜嶥COM锛屽嵆鍒嗗竷寮忕粍浠躲�傚畠鏄熀浜嶫ava鐨勮繙绋嬫柟娉曡皟鐢紙RMI锛夋妧鏈殑锛屾墍浠JB鍙互琚繙绋嬭闂紙璺ㄨ繘绋嬨�佽法璁$畻鏈猴級銆備絾EJB蹇呴』琚竷缃插湪璇稿Webspere銆乄ebLogic杩欐牱鐨勫鍣ㄤ腑锛孍JB瀹㈡埛浠庝笉鐩存帴璁块棶鐪熸鐨凟JB缁勪欢锛岃�屾槸閫氳繃鍏跺鍣ㄨ闂�侲JB瀹瑰櫒鏄疎JB缁勪欢鐨勪唬鐞嗭紝EJB缁勪欢鐢卞鍣ㄦ墍鍒涘缓鍜岀鐞嗐�傚鎴烽�氳繃瀹瑰櫒鏉ヨ闂湡姝g殑EJB缁勪欢銆�4銆丒JB鍖呮嫭锛圫essionBean,EntityBean锛夎鍑轰粬浠殑鐢熷懡鍛ㄦ湡锛屽強濡備綍绠$悊浜嬪姟鐨勶紵SessionBean锛歋tateless Session Bean鐨勭敓鍛藉懆鏈熸槸鐢卞鍣ㄥ喅瀹氱殑锛屽綋瀹㈡埛鏈哄彂鍑鸿姹傝寤虹珛涓�涓狟ean鐨勫疄渚嬫椂锛孍JB瀹瑰櫒涓嶄竴瀹氳鍒涘缓涓�涓柊鐨凚ean鐨勫疄渚嬩緵瀹㈡埛鏈鸿皟鐢紝鑰屾槸闅忎究鎵句竴涓幇鏈夌殑瀹炰緥鎻愪緵缁欏鎴锋満銆傚綋瀹㈡埛鏈虹涓�娆¤皟鐢ㄤ竴涓猄tateful SessionBean 鏃讹紝瀹瑰櫒蹇呴』绔嬪嵆鍦ㄦ湇鍔″櫒涓垱寤轰竴涓柊鐨凚ean瀹炰緥锛屽苟鍏宠仈鍒板鎴锋満涓婏紝浠ュ悗姝ゅ鎴锋満璋冪敤Stateful SessionBean鐨勬柟娉曟椂瀹瑰櫒浼氭妸璋冪敤鍒嗘淳鍒颁笌姝ゅ鎴锋満鐩稿叧鑱旂殑Bean瀹炰緥銆侲ntityBean锛欵ntity Beans鑳藉瓨娲荤浉瀵硅緝闀跨殑鏃堕棿锛屽苟涓旂姸鎬佹槸鎸佺画鐨勩�傚彧瑕佹暟鎹簱涓殑鏁版嵁瀛樺湪锛孍ntity beans灏变竴鐩村瓨娲汇�傝�屼笉鏄寜鐓у簲鐢ㄧ▼搴忔垨鑰呮湇鍔¤繘绋嬫潵璇寸殑銆傚嵆浣縀JB瀹瑰櫒宕╂簝浜嗭紝Entity beans涔熸槸瀛樻椿鐨勩�侲ntity Beans鐢熷懡鍛ㄦ湡鑳藉琚鍣ㄦ垨鑰� Beans鑷繁绠$悊銆侲JB閫氳繃浠ヤ笅鎶�鏈鐞嗗疄鍔★細瀵硅薄绠$悊缁勭粐锛圤MG锛夌殑瀵硅薄瀹炲姟鏈嶅姟锛圤TS锛夛紝Sun Microsystems鐨凾ransaction Service锛圝TS锛夈�丣ava Transaction API锛圝TA锛夛紝寮�鍙戠粍锛圶/Open锛夌殑XA鎺ュ彛銆�5銆丒JB瀹瑰櫒鎻愪緵鐨勬湇鍔′富瑕佹彁渚涘0鏄庡懆鏈熺鐞嗐�佷唬鐮佷骇鐢熴�佹寔缁�х鐞嗐�佸畨鍏ㄣ�佷簨鍔$鐞嗐�侀攣鍜屽苟鍙戣绠$悊绛夋湇鍔°�� 6銆丒JB鐨勬縺娲绘満鍒朵互Stateful Session Bean涓轰緥锛氬叾Cache澶у皬鍐冲畾浜嗗唴瀛樹腑鍙互鍚屾椂瀛樺湪鐨凚ean瀹炰緥鐨勬暟閲忥紝鏍规嵁MRU鎴朜RU绠楁硶锛屽疄渚嬪湪婵�娲诲拰鍘绘縺娲荤姸鎬佷箣闂磋縼绉伙紝婵�娲绘満鍒舵槸褰撳鎴风璋冪敤鏌愪釜EJB瀹炰緥涓氬姟鏂规硶鏃讹紝濡傛灉瀵瑰簲EJB Object鍙戠幇鑷繁娌℃湁缁戝畾瀵瑰簲鐨凚ean瀹炰緥鍒欎粠鍏跺幓婵�娲籅ean瀛樺偍涓紙閫氳繃搴忓垪鍖栨満鍒跺瓨鍌ㄥ疄渚嬶級鍥炲锛堟縺娲伙級姝ゅ疄渚嬨�傜姸鎬佸彉杩佸墠浼氳皟鐢ㄥ搴旂殑ejbActive鍜宔jbPassivate鏂规硶銆�7銆丒JB鐨勫嚑绉嶇被鍨嬩細璇濓紙Session锛塀ean锛屽疄浣擄紙Entity锛塀ean娑堟伅椹卞姩鐨勶紙Message Driven锛塀ean浼氳瘽Bean鍙堝彲鍒嗕负鏈夌姸鎬侊紙Stateful锛夊拰鏃犵姸鎬侊紙Stateless锛変袱绉嶅疄浣揃ean鍙垎涓築ean绠$悊鐨勬寔缁�э紙BMP锛夊拰瀹瑰櫒绠$悊鐨勬寔缁�э紙CMP锛変袱绉�8銆佸鏈嶇璋冪敤EJB瀵硅薄鐨勫嚑涓熀鏈楠よ缃甁NDI鏈嶅姟宸ュ巶浠ュ強JNDI鏈嶅姟鍦板潃绯荤粺灞炴�э紝鏌ユ壘Home鎺ュ彛锛屼粠Home鎺ュ彛璋冪敤Create鏂规硶鍒涘缓Remote鎺ュ彛锛岄�氳繃Remote鎺ュ彛璋冪敤鍏朵笟鍔℃柟娉曘�傚崄涓�. webservice閮ㄥ垎1銆乄EB SERVICE鍚嶈瘝瑙i噴銆侸SWDL寮�鍙戝寘鐨勪粙缁嶃�侸AXP銆丣AXM鐨勮В閲娿�係OAP銆乁DDI,WSDL瑙i噴銆俉eb ServiceWeb Service鏄熀浜庣綉缁滅殑銆佸垎甯冨紡鐨勬ā鍧楀寲缁勪欢锛屽畠鎵ц鐗瑰畾鐨勪换鍔★紝閬靛畧鍏蜂綋鐨勬妧鏈鑼冿紝杩欎簺瑙勮寖浣垮緱Web Service鑳戒笌鍏朵粬鍏煎鐨勭粍浠惰繘琛屼簰鎿嶄綔銆侸AXP(Java API for XML Parsing) 瀹氫箟浜嗗湪Java涓娇鐢―OM, SAX, XSLT鐨勯�氱敤鐨勬帴鍙c�傝繖鏍峰湪浣犵殑绋嬪簭涓綘鍙浣跨敤杩欎簺閫氱敤鐨勬帴鍙o紝褰撲綘闇�瑕佹敼鍙樺叿浣撶殑瀹炵幇鏃跺�欎篃涓嶉渶瑕佷慨鏀逛唬鐮併�侸AXM(Java API for XML Messaging) 鏄负SOAP閫氫俊鎻愪緵璁块棶鏂规硶鍜屼紶杈撴満鍒剁殑API銆俉SDL鏄竴绉� XML鏍煎紡锛岀敤浜庡皢缃戠粶鏈嶅姟鎻忚堪涓轰竴缁勭鐐癸紝杩欎簺绔偣瀵瑰寘鍚潰鍚戞枃妗d俊鎭垨闈㈠悜杩囩▼淇℃伅鐨勬秷鎭繘琛屾搷浣溿�傝繖绉嶆牸寮忛鍏堝鎿嶄綔鍜屾秷鎭繘琛屾娊璞℃弿杩帮紝鐒跺悗灏嗗叾缁戝畾鍒板叿浣撶殑缃戠粶鍗忚鍜屾秷鎭牸寮忎笂浠ュ畾涔夌鐐广�傜浉鍏崇殑鍏蜂綋绔偣鍗崇粍鍚堟垚涓烘娊璞$鐐癸紙鏈嶅姟锛夈�係OAP鍗崇畝鍗曞璞¤闂崗璁�(Simple Object Access Protocol)锛屽畠鏄敤浜庝氦鎹ML缂栫爜淇℃伅鐨勮交閲忕骇鍗忚銆俇DDI 鐨勭洰鐨勬槸涓虹數瀛愬晢鍔″缓绔嬫爣鍑嗭紱UDDI鏄竴濂楀熀浜嶹eb鐨勩�佸垎甯冨紡鐨勩�佷负Web Service鎻愪緵鐨勩�佷俊鎭敞鍐屼腑蹇冪殑瀹炵幇鏍囧噯瑙勮寖锛屽悓鏃朵篃鍖呭惈涓�缁勪娇浼佷笟鑳藉皢鑷韩鎻愪緵鐨刉eb Service娉ㄥ唽锛屼互浣垮埆鐨勪紒涓氳兘澶熷彂鐜扮殑璁块棶鍗忚鐨勫疄鐜版爣鍑嗐��2銆丆ORBA鏄粈涔�?鐢ㄩ�旀槸浠�涔�?CORBA 鏍囧噯鏄叕鍏卞璞¤姹備唬鐞嗙粨鏋�(Common Object Request Broker Architecture)锛岀敱瀵硅薄绠$悊缁勭粐 (Object ManagementGroup锛岀缉鍐欎负 OMG)鏍囧噯鍖栥�傚畠鐨勭粍鎴愭槸鎺ュ彛瀹氫箟璇█(IDL),璇█缁戝畾(binding:涔熻瘧涓鸿仈缂�)鍜屽厑璁稿簲鐢ㄧ▼搴忛棿浜掓搷浣滅殑鍗忚銆傚叾鐩殑涓猴細鐢ㄤ笉鍚岀殑绋嬪簭璁捐璇█涔﹀啓鍦ㄤ笉鍚岀殑杩涚▼涓繍琛岋紝涓轰笉鍚岀殑鎿嶄綔绯荤粺寮�鍙戙��3. Linux4銆丩INUX涓嬬嚎绋嬶紝GDI绫荤殑瑙i噴銆侺INUX瀹炵幇鐨勫氨鏄熀浜庢牳蹇冭交閲忕骇杩涚▼鐨�"涓�瀵逛竴"绾跨▼妯″瀷锛屼竴涓嚎绋嬪疄浣撳搴斾竴涓牳蹇冭交閲忕骇杩涚▼锛岃�岀嚎绋嬩箣闂寸殑绠$悊鍦ㄦ牳澶栧嚱鏁板簱涓疄鐜般�侴DI绫讳负鍥惧儚璁惧缂栫▼鎺ュ彛绫诲簱銆�5. 闂緱绋�閲岀硦娑傜殑棰�6銆佸洓绉嶄細璇濊窡韪妧鏈細璇濅綔鐢ㄥ煙ServletsJSP椤甸潰鎻忚堪page鍚︽槸浠h〃涓庝竴涓〉闈㈢浉鍏崇殑瀵硅薄鍜屽睘鎬с�備竴涓〉闈㈢敱涓�涓紪璇戝ソ鐨� Java servlet绫伙紙鍙互甯︽湁浠讳綍鐨刬nclude鎸囦护锛屼絾鏄病鏈� include鍔ㄤ綔锛夎〃绀恒�傝繖鏃㈠寘鎷� servlet鍙堝寘鎷缂栬瘧鎴� servlet鐨� JSP椤甸潰request鏄槸浠h〃涓� Web瀹㈡埛鏈哄彂鍑虹殑涓�涓姹傜浉鍏崇殑瀵硅薄鍜屽睘鎬с�備竴涓姹傚彲鑳借法瓒婂涓〉闈紝娑夊強澶氫釜Web缁勪欢锛堢敱浜� forward鎸囦护鍜� include鍔ㄤ綔鐨勫叧绯伙級session鏄槸浠h〃涓庣敤浜庢煇涓� Web瀹㈡埛鏈虹殑涓�涓敤鎴蜂綋楠岀浉鍏崇殑瀵硅薄鍜屽睘鎬с�備竴涓� Web浼氳瘽鍙互涔熺粡甯镐細璺ㄨ秺澶氫釜瀹㈡埛鏈鸿姹俛pplication鏄槸浠h〃涓庢暣涓� Web搴旂敤绋嬪簭鐩稿叧鐨勫璞″拰灞炴�с�傝繖瀹炶川涓婃槸璺ㄨ秺鏁翠釜 Web搴旂敤绋嬪簭锛屽寘鎷涓〉闈€�佽姹傚拰浼氳瘽鐨勪竴涓叏灞�浣滅敤鍩�7銆佺畝杩伴�昏緫鎿嶄綔(&,|,^)涓庢潯浠舵搷浣�(&&,||)鐨勫尯鍒�傚尯鍒富瑕佺瓟涓ょ偣锛歛.鏉′欢鎿嶄綔鍙兘鎿嶄綔甯冨皵鍨嬬殑,鑰岄�昏緫鎿嶄綔涓嶄粎鍙互鎿嶄綔甯冨皵鍨�,鑰屼笖鍙互鎿嶄綔鏁板�煎瀷b.閫昏緫鎿嶄綔涓嶄細浜х敓鐭矾 鍗佷簩.鍏朵粬1銆佽鐢ㄨ嫳鏂囩畝鍗曚粙缁嶄竴涓嬭嚜宸�.4銆乄EB SERVICE鍚嶈瘝瑙i噴銆侸SWDL寮�鍙戝寘鐨勪粙缁嶃�侸AXP銆丣AXM鐨勮В閲娿�係OAP銆乁DDI,WSDL瑙i噴銆�2銆佽鎶奾ttp://tomcat.apache.org/ 棣栭〉鐨勮繖涓�娈佃瘽鐢ㄤ腑鏂囩炕璇戜竴涓�?Apache Tomcat is the servlet container that is used in the officialReference Implementation for theJava ServletandJavaServerPages technologies. The Java Servlet and JavaServer Pagesspecifications are developed by Sun under theJavaCommunity Process.Apache Tomcat is developed in an open andparticipatory environment and released under theApacheSoftware License. Apache Tomcat is intended to be a collaboration ofthe best-of-breed developers from around the world. We invite you toparticipate in this open development project. To learn more about gettinginvolved,click here.ApacheTomcat powers numerous large-scale, mission-critical web applications across adiverse range of industries and organizations. Some of these users and theirstories are listed on thePoweredBy wiki page.3銆佺編璧勮蒋浠跺叕鍙窲AVA宸ョ▼甯堢數璇濋潰璇曢鐩�1. Talk about overriding, overloading.2. Talk about JAVA design patterns you known.3. Talk about the difference between LinkList, ArrayList and Victor.4. Talk about the difference between an Abstract class and an Interface.5. Class a = new Class(); Class b = new Class(); if(a == b) returns true or false, why?6. Why we use StringBuffer when concatenating strings?7. Try to explain Singleton to us? Is it thread safe? If no, how to make itthread safe?8. Try to explain Ioc?9. How to set many-to-many relationship in Hibernate?10. Talk about the difference between INNER JOIN and LFET JOIN.11. Why we use index in database? How many indexes is the maximum in one tableas your suggestion?12. When 鈥楩inal鈥� is used in class, method and property, what dose it mean?13. Do you have any experience on XML? Talk about any XML tool youused ,e.g. JAXB, JAXG.14. Do you have any experience on Linux?15. In OOD what is the reason when you create a Sequence diagram?Administrator 10:34:201锛屽爢鍜屾爤鐨勫尯鍒紝鏈変竴涓�64k鐨勫瓧绗︿覆锛屾槸鏀惧埌鍫嗕笂锛岃繕鏄斁鍒版爤涓婏紝涓轰粈涔堬紵2锛屼粈涔堟椂鍊欑敤鍒版帴鍙o紝浠�涔堟椂鍊欑敤鍒版娊璞$被锛屼簩鑰呭尯鍒�3锛屾湁涓�涓�100涓囩殑鏁扮粍锛岄噷杈规湁涓や釜甯傞噸澶嶇殑锛屽浣曡璁$畻娉曟壘鍒般��4锛岃璁℃暟鎹簱鏃讹紝n缁达紝濡備綍璁捐銆備緥濡俒鐪佷唤][鍩庡競][缃戝惂]锛岃繖鏄笁缁村叧绯伙紝瀹冪殑琛ㄤ篃搴旇鏈変笁涓紝缃戝惂鏈夊閿紩鐢ㄥ煄甯傦紝鍩庡競鏈夊閿簲鐢ㄧ渷浠斤紝杩欎釜瑙勫緥灏辨槸涓嬪眰鐨勮鏈変竴澶栭敭鍘诲紩鐢ㄤ笂灞傘��