Java闈㈣瘯

涓�. 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缁达紝濡備綍璁捐銆備緥濡俒鐪佷唤][鍩庡競][缃戝惂]锛岃繖鏄笁缁村叧绯伙紝瀹冪殑琛ㄤ篃搴旇鏈変笁涓紝缃戝惂鏈夊閿紩鐢ㄥ煄甯傦紝鍩庡競鏈夊閿簲鐢ㄧ渷浠斤紝杩欎釜瑙勫緥灏辨槸涓嬪眰鐨勮鏈変竴澶栭敭鍘诲紩鐢ㄤ笂灞傘��

你可能感兴趣的:(Java闈㈣瘯)