锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久久无码精品亚洲日韩,亚洲Aⅴ在线无码播放毛片一线天,97久久精品亚洲中文字幕无码http://m.tkk7.com/czcode/category/18133.htmlzh-cnThu, 15 May 2008 12:39:33 GMTThu, 15 May 2008 12:39:33 GMT60Struts 2澶氭枃浠朵笂浼?/title><link>http://m.tkk7.com/czcode/archive/2008/05/15/200582.html</link><dc:creator>宕旀尟</dc:creator><author>宕旀尟</author><pubDate>Thu, 15 May 2008 02:42:00 GMT</pubDate><guid>http://m.tkk7.com/czcode/archive/2008/05/15/200582.html</guid><wfw:comment>http://m.tkk7.com/czcode/comments/200582.html</wfw:comment><comments>http://m.tkk7.com/czcode/archive/2008/05/15/200582.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/czcode/comments/commentRss/200582.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/czcode/services/trackbacks/200582.html</trackback:ping><description><![CDATA[     鎽樿:   <a href='http://m.tkk7.com/czcode/archive/2008/05/15/200582.html'>闃呰鍏ㄦ枃</a><img src ="http://m.tkk7.com/czcode/aggbug/200582.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/czcode/" target="_blank">宕旀尟</a> 2008-05-15 10:42 <a href="http://m.tkk7.com/czcode/archive/2008/05/15/200582.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>struts2鎷︽埅鍣ㄦ榪?/title><link>http://m.tkk7.com/czcode/archive/2008/05/15/200581.html</link><dc:creator>宕旀尟</dc:creator><author>宕旀尟</author><pubDate>Thu, 15 May 2008 02:39:00 GMT</pubDate><guid>http://m.tkk7.com/czcode/archive/2008/05/15/200581.html</guid><wfw:comment>http://m.tkk7.com/czcode/comments/200581.html</wfw:comment><comments>http://m.tkk7.com/czcode/archive/2008/05/15/200581.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/czcode/comments/commentRss/200581.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/czcode/services/trackbacks/200581.html</trackback:ping><description><![CDATA[     鎽樿:   <a href='http://m.tkk7.com/czcode/archive/2008/05/15/200581.html'>闃呰鍏ㄦ枃</a><img src ="http://m.tkk7.com/czcode/aggbug/200581.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/czcode/" target="_blank">宕旀尟</a> 2008-05-15 10:39 <a href="http://m.tkk7.com/czcode/archive/2008/05/15/200581.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Struts2 鍦ˋction綾諱腑鑾峰緱HttpServletResponse瀵硅薄鐨勫洓縐嶆柟娉?/title><link>http://m.tkk7.com/czcode/archive/2008/05/15/200580.html</link><dc:creator>宕旀尟</dc:creator><author>宕旀尟</author><pubDate>Thu, 15 May 2008 02:37:00 GMT</pubDate><guid>http://m.tkk7.com/czcode/archive/2008/05/15/200580.html</guid><wfw:comment>http://m.tkk7.com/czcode/comments/200580.html</wfw:comment><comments>http://m.tkk7.com/czcode/archive/2008/05/15/200580.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://m.tkk7.com/czcode/comments/commentRss/200580.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/czcode/services/trackbacks/200580.html</trackback:ping><description><![CDATA[     鎽樿:   <a href='http://m.tkk7.com/czcode/archive/2008/05/15/200580.html'>闃呰鍏ㄦ枃</a><img src ="http://m.tkk7.com/czcode/aggbug/200580.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/czcode/" target="_blank">宕旀尟</a> 2008-05-15 10:37 <a href="http://m.tkk7.com/czcode/archive/2008/05/15/200580.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Collection鎺ュ彛鐨勬葷粨 http://m.tkk7.com/czcode/archive/2007/04/18/111549.html宕旀尟宕旀尟Wed, 18 Apr 2007 03:18:00 GMThttp://m.tkk7.com/czcode/archive/2007/04/18/111549.htmlhttp://m.tkk7.com/czcode/comments/111549.htmlhttp://m.tkk7.com/czcode/archive/2007/04/18/111549.html#Feedback0http://m.tkk7.com/czcode/comments/commentRss/111549.htmlhttp://m.tkk7.com/czcode/services/trackbacks/111549.html Map鎺ュ彛錛?/strong>
    |
    + -- WeakHashMap: 浠ュ急閿?瀹炵幇鐨勫熀浜庡搱甯岃〃鐨?Map銆傚湪 WeakHashMap 涓紝褰撴煇涓敭涓嶅啀姝e父浣跨敤鏃訛紝灝嗚嚜鍔ㄧЩ闄ゅ叾鏉?br>    |      鐩傛洿綺劇‘鍦拌錛屽浜庝竴涓粰瀹氱殑閿紝鍏舵槧灝勭殑瀛樺湪騫朵笉闃繪鍨冨溇鍥炴敹鍣ㄥ璇ラ敭鐨勪涪寮冿紝榪欏氨浣胯閿垚涓哄彲緇堟鐨勶紝琚粓
    |      姝紝鐒跺悗琚洖鏀躲備涪寮冩煇涓敭鏃訛紝鍏舵潯鐩粠鏄犲皠涓湁鏁堝湴縐婚櫎錛屽洜姝わ紝璇ョ被鐨勮涓轟笌鍏朵粬鐨?Map 瀹炵幇鏈夋墍涓嶅悓銆?font color=#ff0000>姝ゅ疄鐜?/font>
    |      涓嶆槸鍚屾鐨勩?/font>
    |
    + -- TreeMap:璇ユ槧灝勬牴鎹叾閿殑鑷劧欏哄簭榪涜鎺掑簭錛屾垨鑰呮牴鎹垱寤烘槧灝勬椂鎻愪緵鐨?Comparator 榪涜鎺掑簭錛屽叿浣撳彇鍐充簬浣跨敤鐨?br>    |    鏋勯犳柟娉曘?font color=#ff0000>姝ゅ疄鐜頒笉鏄悓姝ョ殑銆?/font>
    |
    + -- HashMap:鍩轟簬鍝堝笇琛ㄧ殑 Map 鎺ュ彛鐨勫疄鐜般傛瀹炵幇鎻愪緵鎵鏈夊彲閫夌殑鏄犲皠鎿嶄綔錛屽茍鍏佽浣跨敤 null 鍊煎拰 null 閿傦紙闄や簡      
    |        闈炲悓姝ュ拰鍏佽浣跨敤 null 涔嬪錛孒ashMap 綾諱笌 Hashtable 澶ц嚧鐩稿悓銆傦級姝ょ被涓嶄繚璇佹槧灝勭殑欏哄簭錛岀壒鍒槸瀹冧笉淇濊瘉璇ラ『   
    |       搴忔亽涔呬笉鍙樸?font color=#ff0000>姝ゅ疄鐜頒笉鏄悓姝ョ殑銆?br>    |
    +-- SortedMap: 榪涗竴姝ユ彁渚涘叧浜庨敭鐨勬諱綋鎺掑簭 鐨?Map銆傝鏄犲皠鏄牴鎹叾閿殑鑷劧欏哄簭榪涜鎺掑簭鐨勶紝鎴栬呮牴鎹氬父鍦ㄥ垱寤烘湁
         搴忔槧灝勬椂鎻愪緵鐨?Comparator 榪涜鎺掑簭銆傚鏈夊簭鏄犲皠鐨?collection 瑙嗗浘錛堢敱 entrySet銆乲eySet 鍜?values 鏂規硶榪斿洖
         錛夎繘琛岃凱浠f椂錛屾欏哄簭灝變細鍙嶆槧鍑烘潵銆傝閲囩敤姝ゆ帓搴忔柟寮忥紝榪橀渶瑕佹彁渚涗竴浜涘叾浠栨搷浣滐紙姝ゆ帴鍙f槸 SortedSet 鐨勫搴旀槧
         灝勶級銆?br>
Collection鎺ュ彛錛?/strong>
    |
    + -- Set鎺ュ彛:涓涓笉鍖呭惈閲嶅鍏冪礌鐨?collection銆傛洿姝e紡鍦拌錛宻et 涓嶅寘鍚弧瓚?e1.equals(e2) 鐨勫厓绱犲 e1 鍜?e2錛屽茍
    |      |     涓旀渶澶氬寘鍚竴涓?null 鍏冪礌銆傛濡傚叾鍚嶇О鎵鏆楃ず鐨勶紝姝ゆ帴鍙fā浠夸簡鏁板涓婄殑 set 鎶借薄銆?br>    |      |
    |      + -- HashSet:姝ょ被瀹炵幇 Set 鎺ュ彛錛岀敱鍝堝笇琛紙瀹為檯涓婃槸涓涓?HashMap 瀹炰緥錛夋敮鎸併傚畠涓嶄繚璇?set 鐨勮凱浠i『搴忥紱
    |      |    鐗瑰埆鏄畠涓嶄繚璇佽欏哄簭鎭掍箙涓嶅彉銆傛綾誨厑璁鎬嬌鐢?null 鍏冪礌銆傛綾諱負鍩烘湰鎿嶄綔鎻愪緵浜嗙ǔ瀹氭ц兘錛?font color=#ff0000>姝ゅ疄鐜頒笉鏄悓
    |      |    姝ョ殑銆?/font>
    |      |
    |      + -- LinkedHashSet:鍏鋒湁鍙鐭ヨ凱浠i『搴忕殑 Set 鎺ュ彛鐨勫搱甯岃〃鍜岄摼鎺ュ垪琛ㄥ疄鐜般傛瀹炵幇涓?HashSet 鐨勪笉鍚屼箣澶栧湪
    |      |    浜庯紝鍚庤呯淮鎶ょ潃涓涓繍琛屼簬鎵鏈夋潯鐩殑鍙岄噸閾炬帴鍒楄〃銆傛閾炬帴鍒楄〃瀹氫箟浜嗚凱浠i『搴忥紝鍗蟲寜鐓у皢鍏冪礌鎻掑叆鍒?set
    |      |    涓?鐨勯『搴忥紙鎻掑叆欏哄簭錛夎繘琛岃凱浠c傛敞鎰忥紝鎻掑叆欏哄簭涓?鍙楀湪 set 涓噸鏂版彃鍏ョ殑 鍏冪礌鐨勫獎鍝嶃?font color=#ff0000>姝ゅ疄鐜頒笉鏄悓姝?/font>
    |      |    鐨勩?
    |      |
    |      + -- TreeSet:鍩轟簬 TreeMap 鐨?NavigableSet 瀹炵幇銆備嬌鐢ㄥ厓绱犵殑鑷劧欏哄簭瀵瑰厓绱犺繘琛屾帓搴忥紝鎴栬呮牴鎹垱寤?set 鏃?br>    |           鎻愪緵鐨?Comparator 榪涜鎺掑簭錛屽叿浣撳彇鍐充簬浣跨敤鐨勬瀯閫犳柟娉曘傛瀹炵幇涓哄熀鏈搷浣滐紙add銆乺emove 鍜?contains錛?br>    |           鎻愪緵鍙椾繚璇佺殑 log(n) 鏃墮棿寮閿銆?font color=#ff0000>姝ゅ疄鐜頒笉鏄悓姝ョ殑銆?/font>
    |
    + -- List鎺ュ彛:鏈夊簭鐨?collection錛堜篃縐頒負搴忓垪錛夈傛鎺ュ彛鐨勭敤鎴峰彲浠ュ鍒楄〃涓瘡涓厓绱犵殑鎻掑叆浣嶇疆榪涜綺劇‘鍦版帶鍒躲傜敤鎴?br>           |      鍙互鏍規嵁鍏冪礌鐨勬暣鏁扮儲寮曪紙鍦ㄥ垪琛ㄤ腑鐨勪綅緗級璁塊棶鍏冪礌錛屽茍鎼滅儲鍒楄〃涓殑鍏冪礌銆?br>           |
           + -- ArrayList:List 鎺ュ彛鐨勫ぇ灝忓彲鍙樻暟緇勭殑瀹炵幇銆傚疄鐜頒簡鎵鏈夊彲閫夊垪琛ㄦ搷浣滐紝騫跺厑璁稿寘鎷?null 鍦ㄥ唴鐨勬墍鏈夊厓绱犮?br>           |    闄や簡瀹炵幇 List 鎺ュ彛澶栵紝姝ょ被榪樻彁渚涗竴浜涙柟娉曟潵鎿嶄綔鍐呴儴鐢ㄦ潵瀛樺偍鍒楄〃鐨勬暟緇勭殑澶у皬銆傦紙姝ょ被澶ц嚧涓婄瓑鍚屼簬
           |    Vector 綾伙紝闄や簡姝ょ被鏄笉鍚屾鐨勩傦級姣忎釜 ArrayList 瀹炰緥閮芥湁涓涓閲忋傝瀹歸噺鏄寚鐢ㄦ潵瀛樺偍鍒楄〃鍏冪礌鐨勬暟
           |    緇勭殑澶у皬銆傚畠鎬繪槸鑷沖皯絳変簬鍒楄〃鐨勫ぇ灝忋傞殢鐫鍚?ArrayList 涓笉鏂坊鍔犲厓绱狅紝鍏跺閲忎篃鑷姩澧為暱銆傚茍鏈寚瀹氬
           |    闀跨瓥鐣ョ殑緇嗚妭錛屽洜涓鴻繖涓嶅彧鏄坊鍔犲厓绱犱細甯︽潵鍒嗘憡鍥哄畾鏃墮棿寮閿閭f牱綆鍗曘?font color=#ff0000>姝ゅ疄鐜頒笉鏄悓姝ョ殑銆?/font>
           |
           + -- LinkedList:List 鎺ュ彛鐨勯摼鎺ュ垪琛ㄥ疄鐜般傚疄鐜版墍鏈夊彲閫夌殑鍒楄〃鎿嶄綔錛屽茍涓斿厑璁告墍鏈夊厓绱狅紙鍖呮嫭 null錛夈傞櫎浜嗗疄
           |    鐜?List 鎺ュ彛澶栵紝LinkedList 綾昏繕涓哄湪鍒楄〃鐨勫紑澶村強緇撳熬 get銆乺emove 鍜?insert 鍏冪礌鎻愪緵浜嗙粺涓鐨勫懡鍚嶆柟
           |    娉曘傝繖浜涙搷浣滃厑璁稿皢閾炬帴鍒楄〃鐢ㄤ綔鍫嗘爤銆侀槦鍒楁垨鍙岀闃熷垪銆?font color=#ff0000>鎻愪緵鍏堣繘鍏堝嚭闃熷垪鎿嶄綔(FIFO)銆傛瀹炵幇涓嶆槸鍚屾鐨勩?/font>
           |
           + -- Vector:Vector 綾誨彲浠ュ疄鐜板彲澧為暱鐨勫璞℃暟緇勩備笌鏁扮粍涓鏍鳳紝瀹冨寘鍚彲浠ヤ嬌鐢ㄦ暣鏁扮儲寮曡繘琛岃闂殑緇勪歡銆備絾鏄?br>                錛孷ector 鐨勫ぇ灝忓彲浠ユ牴鎹渶瑕佸澶ф垨緙╁皬錛屼互閫傚簲鍒涘緩 Vector 鍚庤繘琛屾坊鍔犳垨縐婚櫎欏圭殑鎿嶄綔銆?font color=#ff0000>姝ゅ疄鐜版槸鍚屾鐨?br>                銆?/font>

宕旀尟 2007-04-18 11:18 鍙戣〃璇勮
]]>
tomcat5.5鏃ュ織http://m.tkk7.com/czcode/archive/2007/01/09/92690.html宕旀尟宕旀尟Tue, 09 Jan 2007 10:42:00 GMThttp://m.tkk7.com/czcode/archive/2007/01/09/92690.htmlhttp://m.tkk7.com/czcode/comments/92690.htmlhttp://m.tkk7.com/czcode/archive/2007/01/09/92690.html#Feedback0http://m.tkk7.com/czcode/comments/commentRss/92690.htmlhttp://m.tkk7.com/czcode/services/trackbacks/92690.html鑷粠鐢ㄤ笂浜唗omcat5.5錛屽彂鐜版棩蹇椾俊鎭病浜嗭紝鍑洪敊浜嗕篃鎵句笉鐫鏈夌敤鐨勪俊鎭紝涓奱pache鎵劇瓟妗堬紝鏋滅劧

Tomcat 5.5 uses Commons Logging throughout its internal code allowing the developer to choose a logging configuration that suits their needs, e.g java.util.logging or Log4J. Commons Logging provides Tomcat the ability to log hierarchially across various log levels without needing to rely on a particular logging implementation.

An important consequence for Tomcat 5.5 is that the <Logger> element found in previous versions to create a localhost_log is no longer a valid nested element of <Context>. Instead, the default Tomcat configuration will use java.util.logging. If the developer wishes to collect detailed internal Tomcat logging (i.e what is happening within the Tomcat engine), then they should configure a logging system such as java.util.logging or log4j as detailed next

涔犳儻鐢╨og4j鏉ラ厤緗甽og淇℃伅鐨勮緭鍑恒?/p>

鏂板緩log4j.properties錛屽唴瀹逛負

log4j.rootLogger=info,Console,R

log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
#log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.Console.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n

log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy.MM.dd HH:mm:ss} %5p %c{1}(%L):聽 %m%n

log4j.logger.org.apache=info, R
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG, R
log4j.logger.org.apache.catalina.core=info, R
log4j.logger.org.apache.catalina.session=info, R

鏈鍚庡洓琛屾槸tomcat鐨勪俊鎭紝濡傛灉鏀逛負debug鏃ュ織鏂囦歡灝嗗崄鍒嗗簽澶с?/p>

灝嗚繖涓枃浠舵斁鍏?{catalina.home}/common/classes涓嬶紝鍐嶅皢log4j.jar鍜宑ommons-logging.jar鏀懼叆${catalina.home}/common/lib涓嬶紝灝卞彲浠ュ湪${catalina.home}/logs/涓嬭鍒版棩蹇椾簡銆?/p>



宕旀尟 2007-01-09 18:42 鍙戣〃璇勮
]]>
鎬庢牱鍔ㄦ佹坊鍔犳枃鏈騫跺鐞?/title><link>http://m.tkk7.com/czcode/archive/2007/01/04/91752.html</link><dc:creator>宕旀尟</dc:creator><author>宕旀尟</author><pubDate>Thu, 04 Jan 2007 06:44:00 GMT</pubDate><guid>http://m.tkk7.com/czcode/archive/2007/01/04/91752.html</guid><wfw:comment>http://m.tkk7.com/czcode/comments/91752.html</wfw:comment><comments>http://m.tkk7.com/czcode/archive/2007/01/04/91752.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://m.tkk7.com/czcode/comments/commentRss/91752.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/czcode/services/trackbacks/91752.html</trackback:ping><description><![CDATA[ <p>鎴戝湪鍋氶」鐩椂鏇劇鍒拌繖涓棶棰橈紝鎬庢牱鍔ㄦ佸湴娣誨姞涓涓枃鏈鎴栨枃浠跺煙錛岃繖鍦ㄧ綉涓婂緢瀹規槗鎵懼埌銆備絾瀵規庢牱澶勭悊鎻愪氦鐨勫姩鎬佹暟鎹氨寰堝皯鏈夎繖鏂歸潰鐨勪俊鎭簡銆傛湰浜虹炕闃呬簡涓浜涜祫鏂欙紝鎶婅嚜宸辯殑鏂規硶鍐欎簡涓嬫潵錛屼互椋ㄨ鑰呫?/p> <p>1.鎻愪氦琛ㄥ崟</p> <p>聽</p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #000000"><html><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><body><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽<form聽name</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">form</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">聽method</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">post</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">聽action</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">add.jsp</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽<input聽name</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">button</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">聽type</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">button聽onClick</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">'additem(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">tb</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">)'聽value</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">娣誨姞>></span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽<table聽id</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">tb</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽</table><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><script聽language</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">javascript</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />function聽additem(id)<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽var聽row</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">cell</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">str</span> <span style="COLOR: #008000">;<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #000000">聽聽row聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽eval(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">document.all[</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+id+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">]</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">).insertRow()</span> <span style="COLOR: #008000">;<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #000000">聽聽if(row聽!</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽null聽)<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽聽{<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽聽聽聽聽cell聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽row.insertCell()</span> <span style="COLOR: #008000">;<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #000000">聽聽聽聽聽聽聽聽str</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000"><input聽type=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">text</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">聽name=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">StuName</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">><input聽type=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">button</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">聽value=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">鍒犻櫎</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">聽onclick='deleteitem(this,</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">tb</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);'></span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽cell.innerHTML</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">str</span> <span style="COLOR: #008000">;<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽聽聽}<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />function聽deleteitem(obj</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">id)<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽var聽rowNum</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">curRow</span> <span style="COLOR: #008000">;<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #000000">聽聽curRow聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽obj.parentNode.parentNode</span> <span style="COLOR: #008000">;<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #000000">聽聽rowNum聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽eval(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">document.all.</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+id).rows.length聽-聽</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #008000">;<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #000000">聽聽eval(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">document.all[</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+id+'</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">'+</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">]</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">).deleteRow(curRow.rowIndex)</span> <span style="COLOR: #008000">;<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> <span style="COLOR: #000000">}<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></script><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽<p><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽聽聽<input聽type</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">submit</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">聽name</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">submit</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">聽value</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">鎻愪氦</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽聽聽</p><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" />聽</form><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></body><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></html><br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> </div> <p>聽</p> <p>2.澶勭悊鏁版嵁</p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">body</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">table聽</span> <span style="COLOR: #ff0000">border</span> <span style="COLOR: #0000ff">="1"</span> <span style="COLOR: #0000ff">><</span> <span style="COLOR: #800000">tr</span> <span style="COLOR: #0000ff">><</span> <span style="COLOR: #800000">td聽</span> <span style="COLOR: #ff0000">colspan</span> <span style="COLOR: #0000ff">="2"</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000">eg</span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">td</span> <span style="COLOR: #0000ff">></</span> <span style="COLOR: #800000">tr</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /> <img id="Codehighlighter1_60_261_Open_Image" onclick="this.style.display='none'; Codehighlighter1_60_261_Open_Text.style.display='none'; Codehighlighter1_60_261_Closed_Image.style.display='inline'; Codehighlighter1_60_261_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="Codehighlighter1_60_261_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_60_261_Closed_Text.style.display='none'; Codehighlighter1_60_261_Open_Image.style.display='inline'; Codehighlighter1_60_261_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /> </span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00"><%</span> <span id="Codehighlighter1_60_261_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_60_261_Open_Text"> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />Enumeration聽params</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">request.getParameterNames();<br /><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /></span> <span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">while</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(params.hasMoreElements()){<br /><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /></span> <span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">String</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">聽name</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(</span> <span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">String</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)params.nextElement();<br /><img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /></span> <span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">String</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">[]聽values</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">request.getParameterValues(name);<br /><img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /></span> <span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">if</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(name.equals(</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">StuName</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)){<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> </span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">tr</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">td</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00"><%</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">name</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%></span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">td</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff"><</span> <span style="COLOR: #800000">td</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /> <img id="Codehighlighter1_296_342_Open_Image" onclick="this.style.display='none'; Codehighlighter1_296_342_Open_Text.style.display='none'; Codehighlighter1_296_342_Closed_Image.style.display='inline'; Codehighlighter1_296_342_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="Codehighlighter1_296_342_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_296_342_Closed_Text.style.display='none'; Codehighlighter1_296_342_Open_Image.style.display='inline'; Codehighlighter1_296_342_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /> </span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00"><%</span> <span id="Codehighlighter1_296_342_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_296_342_Open_Text"> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" /> </span> <span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">for</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(</span> <span style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">int</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">聽index</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">0</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">;index</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5"><</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">values.length;index</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">++</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">){<br /><img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /></span> </span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00"><%</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">=</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">values[index]</span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%></span> <span style="COLOR: #000000"> <br /> <img id="Codehighlighter1_367_368_Open_Image" onclick="this.style.display='none'; Codehighlighter1_367_368_Open_Text.style.display='none'; Codehighlighter1_367_368_Closed_Image.style.display='inline'; Codehighlighter1_367_368_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="Codehighlighter1_367_368_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_367_368_Closed_Text.style.display='none'; Codehighlighter1_367_368_Open_Image.style.display='inline'; Codehighlighter1_367_368_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /> </span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00"><%</span> <span id="Codehighlighter1_367_368_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_367_368_Open_Text"> <span style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">}}</span> </span> <span style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">td</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">tr</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">table</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff"></</span> <span style="COLOR: #800000">body</span> <span style="COLOR: #0000ff">></span> <span style="COLOR: #000000"> <br /> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> </div> <br /> <img src ="http://m.tkk7.com/czcode/aggbug/91752.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/czcode/" target="_blank">宕旀尟</a> 2007-01-04 14:44 <a href="http://m.tkk7.com/czcode/archive/2007/01/04/91752.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Servlet鍜孎ilter鐨剈rl鍖歸厤浠ュ強url-pattern璇﹁Вhttp://m.tkk7.com/czcode/archive/2006/12/18/88456.html宕旀尟宕旀尟Mon, 18 Dec 2006 02:45:00 GMThttp://m.tkk7.com/czcode/archive/2006/12/18/88456.htmlhttp://m.tkk7.com/czcode/comments/88456.htmlhttp://m.tkk7.com/czcode/archive/2006/12/18/88456.html#Feedback0http://m.tkk7.com/czcode/comments/commentRss/88456.htmlhttp://m.tkk7.com/czcode/services/trackbacks/88456.html鍜?/span>filter鏄?/span>J2EE寮鍙戜腑甯哥敤鐨勬妧鏈紝浣跨敤鏂逛究錛岄厤緗畝鍗曪紝鑰佸皯鐨嗗疁銆備及璁″ぇ澶氭暟鏈嬪弸閮芥槸鐩存帴閰嶇疆鐢紝涔熸病鏈夊叧蹇冭繃鍏蜂綋鐨勭粏鑺傦紝浠婂ぉ閬囧埌涓涓棶棰橈紝涓婄綉鏌ヤ簡servlet鐨勮鑼冩墠鍙戠幇錛?/span>servlet鍜?/span>filter涓殑url-pattern榪樻槸鏈変竴浜涙枃绔犲湪閲岄潰鐨勶紝鎬葷粨浜嗕竴浜涗笢瑗匡紝鏀懼嚭鏉ヤ緵澶у鍙傝冿紝浠ュ厤閬囧埌闂鍙堣嫻垂鏃墮棿銆?/span>

聽聽聽 涓錛?/font>servlet瀹瑰櫒瀵?/span>url鐨勫尮閰嶈繃紼嬶細

聽聽聽聽聽

褰撲竴涓姹傚彂閫佸埌servlet瀹瑰櫒鐨勬椂鍊欙紝瀹瑰櫒鍏堜細灝嗚姹傜殑url鍑忓幓褰撳墠搴旂敤涓婁笅鏂囩殑璺緞浣滀負servlet鐨勬槧灝?/span>url錛屾瘮濡傛垜璁塊棶鐨勬槸http://localhost/test/aaa.html錛屾垜鐨勫簲鐢ㄤ笂涓嬫枃鏄?/span>test錛屽鍣ㄤ細灝?/span>http://localhost/test鍘繪帀錛屽墿涓嬬殑/aaa.html閮ㄥ垎鎷挎潵鍋?/span>servlet鐨勬槧灝勫尮閰嶃傝繖涓槧灝勫尮閰嶈繃紼嬫槸鏈夐『搴忕殑錛岃屼笖褰撴湁涓涓?/span>servlet鍖歸厤鎴愬姛浠ュ悗錛屽氨涓嶄細鍘葷悊浼氬墿涓嬬殑servlet浜嗭紙filter涓嶅悓錛屽悗鏂囦細鎻愬埌錛夈傚叾鍖歸厤瑙勫垯鍜岄『搴忓涓嬶細

1.聽聽聽聽 綺劇‘璺緞鍖歸厤銆備緥瀛愶細姣斿servletA 鐨?/span>url-pattern涓?/span> /test錛?/span>servletB鐨?/span>url-pattern涓?/span>/* 錛岃繖涓椂鍊欙紝濡傛灉鎴戣闂殑url涓?/span>http://localhost/test錛岃繖涓椂鍊欏鍣ㄥ氨浼氬厛榪涜綺劇‘璺緞鍖歸厤錛屽彂鐜?/span>/test姝eソ琚?/span>servletA綺劇‘鍖歸厤錛岄偅涔堝氨鍘昏皟鐢?/span>servletA錛屼篃涓嶄細鍘葷悊浼氬叾浠栫殑servlet浜嗐?/span>

2.聽聽聽聽 鏈闀胯礬寰勫尮閰嶃備緥瀛愶細servletA鐨?/span>url-pattern涓?/span>/test/*錛岃?/span>servletB鐨?/span>url-pattern涓?/span>/test/a/*錛屾鏃惰闂?/span>http://localhost/test/a鏃訛紝瀹瑰櫒浼氶夋嫨璺緞鏈闀跨殑servlet鏉ュ尮閰嶏紝涔熷氨鏄繖閲岀殑servletB銆?/span>

3.聽聽聽聽 鎵╁睍鍖歸厤錛屽鏋?/span>url鏈鍚庝竴孌靛寘鍚墿灞曪紝瀹瑰櫒灝嗕細鏍規嵁鎵╁睍閫夋嫨鍚堥傜殑servlet銆備緥瀛愶細servletA鐨?/span>url-pattern錛?/span>*.action

4.聽聽聽聽 濡傛灉鍓嶉潰涓夋潯瑙勫垯閮芥病鏈夋壘鍒頒竴涓?/span>servlet錛屽鍣ㄤ細鏍規嵁url閫夋嫨瀵瑰簲鐨勮姹傝祫婧愩傚鏋滃簲鐢ㄥ畾涔変簡涓涓?/span>default servlet錛屽垯瀹瑰櫒浼氬皢璇鋒眰涓㈢粰default servlet錛堜粈涔堟槸default servlet錛熷悗闈細璁詫級銆?/span>

聽聽聽 鏍規嵁榪欎釜瑙勫垯琛紝灝辮兘寰堟竻妤氱殑鐭ラ亾servlet鐨勫尮閰嶈繃紼嬶紝鎵浠ュ畾涔?/span>servlet鐨勬椂鍊欎篃瑕佽冭檻url-pattern鐨勫啓娉曪紝浠ュ厤鍑洪敊銆?/span>

聽聽聽聽聽 瀵逛簬filter錛屼笉浼氬儚servlet閭f牱鍙尮閰嶄竴涓?/span>servlet錛屽洜涓?/span>filter鐨勯泦鍚堟槸涓涓摼錛屾墍浠ュ彧浼氭湁澶勭悊鐨勯『搴忎笉鍚岋紝鑰屼笉浼氬嚭鐜板彧閫夋嫨涓涓?/span>filter銆?/span>Filter鐨勫鐞嗛『搴忓拰filter-mapping鍦?/span>web.xml涓畾涔夌殑欏哄簭鐩稿悓銆?/span>

聽聽聽 浜岋紝url-pattern璇﹁В

聽聽聽聽聽聽聽聽 鍦?/span>web.xml鏂囦歡涓紝浠ヤ笅璇硶鐢ㄤ簬瀹氫箟鏄犲皠錛?/span>

l浠?/span>鈥?鈥?/span>寮澶村拰浠?/span>鈥?*鈥?/span>緇撳熬鐨勬槸鐢ㄦ潵鍋氳礬寰勬槧灝勭殑銆?/span>

l浠ュ墠緙鈥?.鈥?/span>寮澶寸殑鏄敤鏉ュ仛鎵╁睍鏄犲皠鐨勩?/span>

l鈥?鈥?鏄敤鏉ュ畾涔?/span>default servlet鏄犲皠鐨勩?/span>

l鍓╀笅鐨勯兘鏄敤鏉ュ畾涔夎緇嗘槧灝勭殑銆傛瘮濡傦細 /aa/bb/cc.action

鎵浠ワ紝涓轟粈涔堝畾涔?/span>鈥?*.action鈥?/span>榪欐牱涓涓湅璧鋒潵寰堟甯哥殑鍖歸厤浼氶敊錛熷洜涓鴻繖涓尮閰嶅嵆灞炰簬璺緞鏄犲皠錛屼篃灞炰簬鎵╁睍鏄犲皠錛屽鑷村鍣ㄦ棤娉曞垽鏂?/span>



宕旀尟 2006-12-18 10:45 鍙戣〃璇勮
]]>
saveorUpdate涓巙nsaved-value錛宻ave錛寀pdate錛宒eletehttp://m.tkk7.com/czcode/archive/2006/12/18/88453.html宕旀尟宕旀尟Mon, 18 Dec 2006 02:40:00 GMThttp://m.tkk7.com/czcode/archive/2006/12/18/88453.htmlhttp://m.tkk7.com/czcode/comments/88453.htmlhttp://m.tkk7.com/czcode/archive/2006/12/18/88453.html#Feedback0http://m.tkk7.com/czcode/comments/commentRss/88453.htmlhttp://m.tkk7.com/czcode/services/trackbacks/88453.html 甯屾湜瀵瑰垰寮濮嬪Hibernate鐨勫悓瀛︽湁鎵甯姪銆?/strong>

涓銆乻aveorUpdate涓巙nsaved-value
鍒板簳鏄痵ava榪樻槸update
Hibernate闇瑕佸垽鏂鎿嶄綔鐨勫璞$┒绔熸槸涓涓凡緇忔寔涔呭寲榪囩殑鎸佷箙瀵硅薄榪樻槸涓存椂瀵硅薄銆?
1錛夛紟涓婚敭Hibernate鐨刬d generator浜х敓
<id name="id" type="java.lang.Long">
<column name="ID" precision="22" scale="0" />
<generator class="increment" />
</id>

Project project = new Project();
project.setId(XXX);
this.projectDao.saveOrUpdate(project);

1銆侀粯璁nsaved-value="null"
涓婚敭鏄璞$被鍨嬶紝hebernate鍒ゆ柇project鐨勪富閿槸鍚︿綅null錛屾潵鍒ゆ柇project鏄惁宸茶鎸佷箙鍖?/b>
鏄殑璇濓紝瀵筽roject瀵硅薄鍙戦乻ave(project)錛?
鑻ヨ嚜宸辮緗簡涓婚敭鍒欑洿鎺ョ敓鎴恥pdate鐨剆ql錛屽彂閫乽pdate(project)錛屽嵆渚挎暟鎹簱閲屾病鏈夐偅鏉¤褰曘?
涓婚敭鏄熀鏈被鍨嬪int/long/double/
鑷繁璁劇疆unsaved-null="0"銆?
鎵浠ヨ繖鏍風殑璇漵ave鍜寀pdate鎿嶄綔鑲畾涓嶄細鎶ラ敊銆?/p>

2銆乽nsaved-value="none"錛?
鐢變簬涓嶈涓婚敭灞炴т負浠諱綍鍊鹼紝閮戒笉鍙兘涓簄one錛屽洜姝ibernate鎬繪槸瀵筽roject瀵硅薄鍙戦乽pdate(project)

3銆乽nsaved-value="any"
鐢變簬涓嶈涓婚敭灞炴т負浠諱綍鍊鹼紝閮借偗瀹氫負any錛屽洜姝ibernate鎬繪槸瀵筽roject瀵硅薄鍙戦乻ave(project)錛宧ibernate鐢熸垚涓婚敭銆?/p>

Hibernate鏂囨。涓啓鍒?
saveOrUpdate()瀹屾垚浜嗗涓嬪伐浣滐細
濡傛灉瀵硅薄宸茬粡鍦ㄨ繖涓猻ession涓寔涔呭寲榪囦簡錛屼粈涔堥兘涓嶇敤鍋?
濡傛灉瀵硅薄娌℃湁鏍囪瘑鍊鹼紝璋冪敤save()鏉ヤ繚瀛樺畠
濡傛灉瀵硅薄鐨勬爣璇嗗間笌unsaved-value涓殑鏉′歡鍖歸厤錛岃皟鐢╯ave()鏉ヤ繚瀛樺畠
濡傛灉瀵硅薄浣跨敤浜嗙増鏈?version鎴杢imestamp),閭d箞闄ら潪璁劇疆unsaved-value="undefined",鐗堟湰媯鏌ヤ細鍙戠敓鍦ㄦ爣璇嗙媯鏌ヤ箣鍓?
濡傛灉榪欎釜session涓湁鍙﹀涓涓璞″叿鏈夊悓鏍風殑鏍囪瘑絎︼紝鎶涘嚭涓涓紓甯?

2錛夛紟涓婚敭鐢辮嚜宸辨潵璧嬪?/b>
<id name="id" type="java.lang.Long">
<column name="ID" precision="22" scale="0" />
<generator class="assigned" />
</id>

Project project = new Project();
project.setId(XXX);
this.projectDao.saveOrUpdate(project);

1銆侀粯璁nsaved-value="null"
榪欐椂鏈夋墍涓嶅悓錛宧ibernate浼氭牴鎹富閿駭鐢熶竴涓猻elect錛屾潵鍒ゆ柇姝ゅ璞℃槸鍚﹀凡琚寔涔呭寲
宸茶鎸佷箙鍖栧垯update錛屾湭琚寔涔呭寲鍒檚ave銆?
2銆乽nsaved-value="none"錛寀pdate瀵硅薄錛屽悓涓?/p>

3銆乽nsaved-value="any" 錛宻ave瀵硅薄錛?
濡傛灉鑷繁鑷繁璁劇疆鐨処D鍦ㄦ暟鎹簱涓凡瀛樺湪錛屽垯鎶ラ敊銆?/p>

浜屻乻ave涓巙pdate鎿嶄綔
鏄懼紡鐨勪嬌鐢╯ession.save()鎴栬卻ession.update()鎿嶄綔涓涓璞$殑鏃跺欙紝瀹為檯涓婃槸鐢ㄤ笉鍒皍nsaved-value鐨?
鍦ㄥ悓涓Session錛宻ave娌′粈涔堝彲璇村緱
update瀵硅薄鏃? 鏈鐩存帴鐨勬洿鏀逛竴涓璞$殑鏂規硶灝辨槸load()瀹冿紝淇濇寔Session鎵撳紑錛岀劧鍚庣洿鎺ヤ慨鏀瑰嵆鍙?
Session s =鈥?
Project p = (Project) sess.load(Project.class, id) );
p.setName(鈥渢est鈥?;
s.flush();
涓嶇敤璋冪敤s.update(p);hibernate鑳藉療瑙夊埌瀹冪殑鍙樺寲錛屼細鑷姩鏇存柊銆傚綋鐒舵樉紺鴻皟鐢ㄧ殑璇濅篃涓嶄細閿?/p>

Hibernate鏂囨。涓啓鍒?
update()鏂規硶鍦ㄤ笅鍒楁儏褰笅浣跨敤錛?
紼嬪簭鍦ㄥ墠闈㈢殑session涓杞戒簡瀵硅薄
瀵硅薄琚紶閫掑埌UI錛堢晫闈級灞?
瀵硅瀵硅薄榪涜浜嗕竴浜涗慨鏀?
瀵硅薄琚紶閫掑洖涓氬姟灞?
搴旂敤紼嬪簭鍦ㄧ浜屼釜session涓皟鐢╱pdate()淇濆瓨淇敼

涓夈乨elete鎿嶄綔
鍒犻櫎鏃剁洿鎺ヨ嚜宸辨瀯閫犱竴涓猵roject鍗沖彲鍒犻櫎
this.projectDao.delete(preojct);

浠ュ墠鍒犻櫎鎴戞槸榪欐牱鍐欑殑
public void deleteProject(String id) {
Project project = (Project) this.projectDao.get(Project.class, id);
if (project != null) {
this.projectDao.delete(project);
}
鍗寵繖鏍蜂篃鏄彲浠ョ殑
Project project = new Project();
project.setId(id);
this.projectDao.delete(project).

濡傛灉鏈夌駭鑱斿叧緋伙紝闇瑕佹妸綰ц仈鐨勫瓙綾諱篃鏋勯犲嚭鏉dd榪涘幓錛屽悓鏍峰彲浠ュ垹闄ゃ?/p>

濂戒簡錛岀綏鍡︾殑澶熷浜嗐?/p>

宕旀尟 2006-12-18 10:40 鍙戣〃璇勮
]]>
POI 鎼瀍xcellhttp://m.tkk7.com/czcode/archive/2006/12/18/88450.html宕旀尟宕旀尟Mon, 18 Dec 2006 02:36:00 GMThttp://m.tkk7.com/czcode/archive/2006/12/18/88450.htmlhttp://m.tkk7.com/czcode/comments/88450.htmlhttp://m.tkk7.com/czcode/archive/2006/12/18/88450.html#Feedback0http://m.tkk7.com/czcode/comments/commentRss/88450.htmlhttp://m.tkk7.com/czcode/services/trackbacks/88450.html

1銆侀亶鍘唚orkbook

浠g爜
  1. //聽load婧愭枃浠? 聽聽
  2. POIFSFileSystem聽fs聽=聽 new 聽POIFSFileSystem( new 聽FileInputStream(filePath)); 聽聽
  3. HSSFWorkbook聽wb聽=聽 new 聽HSSFWorkbook(fs); 聽聽
  4. for 聽( int 聽i聽=聽 0 ;聽i聽<聽wb.getNumberOfSheets();聽i++)聽{ 聽聽
  5. 聽聽聽聽HSSFSheet聽sheet聽=聽wb.getSheetAt(i); 聽聽
  6. 聽聽聽聽 for 聽( int 聽i聽=聽sheet.getFirstRowNum();聽i聽<聽sheet.getLastRowNum();聽i聽++)聽{ 聽聽
  7. 聽聽聽聽HSSFRow聽row聽=聽sheet.getRow(i); 聽聽
  8. 聽聽聽聽聽聽聽聽聽聽聽聽 if 聽(row聽!=聽 null )聽{ 聽聽
  9. 聽聽聽聽聽聽聽聽銆傘傘傛搷浣渳 聽聽
  10. 聽聽聽聽聽聽聽} 聽聽
  11. 聽聽聽聽聽} 聽聽
  12. //聽鐩爣鏂囦歡 聽聽
  13. FileOutputStream聽fos聽=聽 new 聽FileOutputStream(objectPath); 聽聽
  14. //鍐欐枃浠? 聽聽
  15. swb.write(fos); 聽聽
  16. fos.close();聽聽

2銆佸緱鍒板垪鍜屽崟鍏冩牸

浠g爜
  1. HSSFRow聽row聽=聽sheet.getRow(i); 聽聽
  2. HSSFCell聽cell聽=聽row.getCell(( short )聽j);聽聽

3銆佽緗畇heet鍚嶇О鍜屽崟鍏冩牸鍐呭涓轟腑鏂?/b>

浠g爜
  1. wb.setSheetName(n,聽 "涓枃" ,HSSFCell.ENCODING_UTF_16);聽聽聽聽 聽聽
  2. cell.setEncoding(( short )聽 1 ); 聽聽
  3. cell.setCellValue( "涓枃" );聽聽

4銆佸崟鍏冩牸鍐呭鏈叕寮忔垨鏁板鹼紝鍙互榪欐牱璇誨啓

浠g爜
  1. cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); 聽聽
  2. cell.getNumericCellValue()聽聽


5銆佽緗垪瀹姐佽楂?/b>

浠g爜
  1. sheet.setColumnWidth(( short )column,( short )width); 聽聽
  2. row.setHeight(( short )height);聽聽


6銆佹坊鍔犲尯鍩燂紝鍚堝茍鍗曞厓鏍?/b>

浠g爜
  1. Region聽region聽=聽 new 聽Region(( short )rowFrom,( short )columnFrom,( short )rowTo,( short )columnTo); 聽聽
  2. sheet.addMergedRegion(region); 聽聽
  3. //寰楀埌鎵鏈夊尯鍩? 聽聽
  4. sheet.getNumMergedRegions()聽聽

7銆佸父鐢ㄦ柟娉?/b>
鏍規嵁鍗曞厓鏍間笉鍚屽睘鎬ц繑鍥炲瓧絎︿覆鏁板?

浠g爜
  1. public 聽String聽getCellStringValue(HSSFCell聽cell)聽{ 聽聽
  2. 聽聽聽聽聽聽聽聽String聽cellValue聽=聽 "" ; 聽聽
  3. 聽聽聽聽聽聽聽聽 switch 聽(cell.getCellType())聽{ 聽聽
  4. 聽聽聽聽聽聽聽聽 case 聽HSSFCell.CELL_TYPE_STRING: 聽聽
  5. 聽聽聽聽聽聽聽聽聽聽聽聽cellValue聽=聽cell.getStringCellValue(); 聽聽
  6. 聽聽聽聽聽聽聽聽聽聽聽聽 if (cellValue.trim().equals( "" )||cellValue.trim().length()<= 0 ) 聽聽
  7. 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽cellValue= "聽" ; 聽聽
  8. 聽聽聽聽聽聽聽聽聽聽聽聽 break ; 聽聽
  9. 聽聽聽聽聽聽聽聽 case 聽HSSFCell.CELL_TYPE_NUMERIC: 聽聽
  10. 聽聽聽聽聽聽聽聽聽聽聽聽cellValue聽=聽String.valueOf(cell.getNumericCellValue()); 聽聽
  11. 聽聽聽聽聽聽聽聽聽聽聽聽 break ; 聽聽
  12. 聽聽聽聽聽聽聽聽 case 聽HSSFCell.CELL_TYPE_FORMULA: 聽聽
  13. 聽聽聽聽聽聽聽聽聽聽聽聽cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); 聽聽
  14. 聽聽聽聽聽聽聽聽聽聽聽聽cellValue聽=聽String.valueOf(cell.getNumericCellValue()); 聽聽
  15. 聽聽聽聽聽聽聽聽聽聽聽聽 break ; 聽聽
  16. 聽聽聽聽聽聽聽聽 case 聽HSSFCell.CELL_TYPE_BLANK: 聽聽
  17. 聽聽聽聽聽聽聽聽聽聽聽聽cellValue= "聽" ; 聽聽
  18. 聽聽聽聽聽聽聽聽聽聽聽聽 break ; 聽聽
  19. 聽聽聽聽聽聽聽聽 case 聽HSSFCell.CELL_TYPE_BOOLEAN: 聽聽
  20. 聽聽聽聽聽聽聽聽聽聽聽聽 break ; 聽聽
  21. 聽聽聽聽聽聽聽聽 case 聽HSSFCell.CELL_TYPE_ERROR: 聽聽
  22. 聽聽聽聽聽聽聽聽聽聽聽聽 break ; 聽聽
  23. 聽聽聽聽聽聽聽聽 default : 聽聽
  24. 聽聽聽聽聽聽聽聽聽聽聽聽 break ; 聽聽
  25. 聽聽聽聽聽聽聽聽} 聽聽
  26. 聽聽聽聽聽聽聽聽 return 聽cellValue; 聽聽
  27. 聽聽聽聽}聽聽


8銆佸父鐢ㄥ崟鍏冩牸杈規鏍煎紡

铏氱嚎HSSFCellStyle.BORDER_DOTTED
瀹炵嚎HSSFCellStyle.BORDER_THIN

浠g爜
  1. public static 聽HSSFCellStyle聽getCellStyle( short 聽type) 聽聽
  2. 聽聽聽聽{聽聽聽 聽聽
  3. 聽聽聽聽聽聽聽HSSFWorkbook聽wb聽=聽 new 聽HSSFWorkbook(); 聽聽
  4. 聽聽聽聽聽聽聽HSSFCellStyle聽style聽=聽wb.createCellStyle(); 聽聽
  5. 聽聽聽聽聽聽聽style.setBorderBottom(type); //涓嬭竟妗喡? 聽聽
  6. 聽聽聽聽聽聽聽聽style.setBorderLeft(type); //宸﹁竟妗喡? 聽聽
  7. 聽聽聽聽聽聽聽聽style.setBorderRight(type); //鍙寵竟妗喡? 聽聽
  8. 聽聽聽聽聽聽聽聽style.setBorderTop(type); //涓婅竟妗喡? 聽聽
  9. 聽聽聽聽聽聽聽 return 聽style; 聽聽
  10. 聽聽聽聽}聽聽


9銆佽緗瓧浣撳拰鍐呭浣嶇疆

浠g爜
  1. HSSFFont聽f聽聽=聽wb.createFont(); 聽聽
  2. f.setFontHeightInPoints(( short )聽 11 ); //瀛楀彿 聽聽
  3. f.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL); //鍔犵矖 聽聽
  4. style.setFont(f); 聽聽
  5. style.setAlignment(HSSFCellStyle.ALIGN_CENTER); //宸﹀彸灞呬腑 聽聽
  6. style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); //涓婁笅灞呬腑 聽聽
  7. style.setRotation( short 聽rotation); //鍗曞厓鏍煎唴瀹圭殑鏃嬭漿鐨勮搴? 聽聽
  8. HSSFDataFormat聽df聽=聽wb.createDataFormat(); 聽聽
  9. style1.setDataFormat(df.getFormat( "0.00%" )); //璁劇疆鍗曞厓鏍兼暟鎹牸寮? 聽聽
  10. cell.setCellFormula(string); //緇欏崟鍏冩牸璁懼叕寮? 聽聽
  11. style.setRotation( short 聽rotation); //鍗曞厓鏍煎唴瀹圭殑鏃嬭漿鐨勮搴? 聽聽
  12. cell.setCellStyle(style); 聽聽


10銆佹彃鍏ュ浘鐗?/b>
璁哄潧閲岀湅鍒扮殑
浠g爜
  1. //鍏堟妸璇昏繘鏉ョ殑鍥劇墖鏀懼埌涓涓狟yteArrayOutputStream涓紝浠ヤ究浜х敓ByteArray 聽聽
  2. 聽聽聽聽聽聽ByteArrayOutputStream聽byteArrayOut聽=聽new聽ByteArrayOutputStream(); 聽聽
  3. 聽聽聽聽聽聽BufferedImage聽bufferImg聽=聽ImageIO.read(new聽File("ok.jpg")); 聽聽
  4. 聽聽聽聽聽聽ImageIO.write(bufferImg,"jpg",byteArrayOut); 聽聽
  5. //璇昏繘涓涓猠xcel妯$増 聽聽
  6. FileInputStream聽fos聽=聽new聽FileInputStream(filePathName+"/stencil.xlt");聽 聽聽
  7. fs聽=聽new聽POIFSFileSystem(fos); 聽聽
  8. //鍒涘緩涓涓伐浣滆杽 聽聽
  9. HSSFWorkbook聽wb聽=聽new聽HSSFWorkbook(fs); 聽聽
  10. HSSFSheet聽sheet聽=聽wb.getSheetAt(0); 聽聽
  11. HSSFPatriarch聽patriarch聽=聽sheet.createDrawingPatriarch(); 聽聽
  12. HSSFClientAnchor聽anchor聽=聽new聽HSSFClientAnchor(0,0,1023,255,(short)聽0,0,(short)10,10);聽聽聽聽聽 聽聽
  13. patriarch.createPicture(anchor聽,聽wb.addPicture(byteArrayOut.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG));聽聽

鏈鍚庢洿鏂幫細2006-10-30 20:12


宕旀尟 2006-12-18 10:36 鍙戣〃璇勮
]]>
鍒╃敤Java錛婸OI 璇誨啓Excel鏂囨。&鍚慐xcel涓彃鍏ュ浘鐗?/title><link>http://m.tkk7.com/czcode/archive/2006/12/18/88448.html</link><dc:creator>宕旀尟</dc:creator><author>宕旀尟</author><pubDate>Mon, 18 Dec 2006 02:35:00 GMT</pubDate><guid>http://m.tkk7.com/czcode/archive/2006/12/18/88448.html</guid><wfw:comment>http://m.tkk7.com/czcode/comments/88448.html</wfw:comment><comments>http://m.tkk7.com/czcode/archive/2006/12/18/88448.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://m.tkk7.com/czcode/comments/commentRss/88448.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/czcode/services/trackbacks/88448.html</trackback:ping><description><![CDATA[ <p> <font face="瀹嬩綋" size="2">涓錛嶱OI綆浠?/font> </p> <p> <font face="瀹嬩綋" size="2">Jakarta POI 鏄痑pache鐨勫瓙欏圭洰錛岀洰鏍囨槸澶勭悊ole2瀵硅薄銆傚畠鎻愪緵浜嗕竴緇勬搷綰礧indows鏂囨。鐨凧ava API</font> </p> <p> <font face="瀹嬩綋" size="2">鐩墠姣旇緝鎴愮啛鐨勬槸HSSF鎺ュ彛錛屽鐞哅S Excel錛?7-2002錛夊璞°傚畠涓嶈薄鎴戜滑浠呬粎鏄敤csv鐢熸垚鐨勬病鏈夋牸寮忕殑鍙互鐢盓xcel杞崲鐨勪笢瑗匡紝鑰屾槸鐪熸鐨凟xcel瀵硅薄錛屼綘鍙互鎺у埗涓浜涘睘鎬уsheet,cell絳夌瓑銆?/font> </p> <p> <font face="瀹嬩綋" size="2">浜岋紟HSSF姒傚喌</font> </p> <p> <font face="瀹嬩綋" size="2">HSSF 鏄疕orrible SpreadSheet Format鐨勭緝鍐欙紝涔熷嵆鈥滆鍘岀殑鐢靛瓙琛ㄦ牸鏍煎紡鈥濄備篃璁窰SSF鐨勫悕瀛楁湁鐐規粦紼斤紝灝辨湰璐ㄨ岃█瀹冩槸涓涓潪甯鎬弗鑲冦佹瑙勭殑API銆傞氳繃HSSF錛屼綘鍙互鐢ㄧ函Java浠g爜鏉ヨ鍙栥佸啓鍏ャ佷慨鏀笶xcel鏂囦歡銆?/font> </p> <p> <font face="瀹嬩綋" size="2">HSSF 涓鴻鍙栨搷浣滄彁渚涗簡涓ょ被API錛歶sermodel鍜宔ventusermodel錛屽嵆鈥滅敤鎴鋒ā鍨嬧濆拰鈥滀簨浠?鐢ㄦ埛妯″瀷鈥濄傚墠鑰呭緢濂界悊瑙o紝鍚庤呮瘮杈冩娊璞★紝浣嗘搷浣滄晥鐜囪楂樺緱澶氥?/font> </p> <p> <font face="瀹嬩綋" size="2">涓夛紟寮濮嬬紪鐮?/font> </p> <p> <font face="瀹嬩綋" size="2">1 錛?鍑嗗宸ヤ綔</font> </p> <p> <font face="瀹嬩綋" size="2">瑕佹眰:JDK 1.4+POI寮鍙戝寘</font> </p> <p> <font face="瀹嬩綋" size="2">鍙互鍒?/font> <a > <font face="瀹嬩綋" size="2">http://www.apache.org/dyn/closer.cgi/jakarta/poi/</font> </a> <font face="瀹嬩綋" size="2">鏈鏂扮殑POI宸ュ叿鍖?/font> </p> <p> <font face="瀹嬩綋" size="2">2 錛?EXCEL 緇撴瀯</font> </p> <p> <font face="瀹嬩綋" size="2">HSSFWorkbook excell 鏂囨。瀵硅薄浠嬬粛<br />HSSFSheet excell鐨勮〃鍗?br />HSSFRow excell鐨勮<br />HSSFCell excell鐨勬牸瀛愬崟鍏?br />HSSFFont excell瀛椾綋<br />HSSFName 鍚嶇О<br />HSSFDataFormat 鏃ユ湡鏍煎紡<br />鍦╬oi1.7涓墠鏈変互涓?欏癸細<br />HSSFHeader sheet澶?br />HSSFFooter sheet灝?br />鍜岃繖涓牱寮?br />HSSFCellStyle cell鏍峰紡<br />杈呭姪鎿嶄綔鍖呮嫭<br />HSSFDateUtil 鏃ユ湡<br />HSSFPrintSetup 鎵撳嵃<br />HSSFErrorConstants 閿欒淇℃伅琛?/font> </p> <p> <font face="瀹嬩綋" size="2">3 錛庡叿浣撶敤娉曞疄渚?錛堥噰鐢?usermodel 錛?/font> </p> <p> <font face="瀹嬩綋" size="2">濡備綍璇籈xcel</font> </p> <p> <font face="瀹嬩綋" size="2">璇誨彇Excel鏂囦歡鏃訛紝棣栧厛鐢熸垚涓涓狿OIFSFileSystem瀵硅薄錛岀敱POIFSFileSystem瀵硅薄鏋勯犱竴涓狧SSFWorkbook錛岃HSSFWorkbook瀵硅薄灝變唬琛ㄤ簡Excel鏂囨。銆備笅闈唬鐮佽鍙栦笂闈㈢敓鎴愮殑Excel鏂囦歡鍐欏叆鐨勬秷鎭瓧涓詫細<br />try{<br />聽聽 POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream("d:/workbook.xls"));<br />聽聽 HSSFWorkbook wb = new HSSFWorkbook(fs);<br />聽聽 HSSFSheet sheet = wb.getSheetAt(0);<br />聽聽 HSSFRow row = sheet.getRow(0);<br />聽聽 HSSFCell cell = row.getCell((short) 0);<br />聽聽 String msg = cell.getStringCellValue();<br />聽聽 System.out.println(msg);<br />聽 }catch(Exception e){<br />聽聽 e.printStackTrace();<br />聽 }</font> </p> <p> <font face="瀹嬩綋" size="2">濡備綍鍐檈xcel錛?/font> </p> <p> <font face="瀹嬩綋" size="2">灝唀xcel鐨勭涓涓〃鍗曠涓琛岀殑絎竴涓崟鍏冩牸鐨勫煎啓鎴愨渁 test鈥濄?/font> </p> <p> <font face="瀹嬩綋" size="2">POIFSFileSystem fs =new POIFSFileSystem(new FileInputStream("workbook.xls"));</font> </p> <p> <font face="瀹嬩綋" size="2">聽聽聽 HSSFWorkbook wb = new HSSFWorkbook(fs);</font> </p> <p> <font face="瀹嬩綋" size="2">聽聽聽 HSSFSheet sheet = wb.getSheetAt(0);</font> </p> <p> <font face="瀹嬩綋" size="2">聽聽聽 HSSFRow row = sheet.getRow(0);</font> </p> <p> <font face="瀹嬩綋" size="2">聽聽聽 HSSFCell cell = row.getCell((short)0);</font> </p> <p> <font face="瀹嬩綋" size="2">聽聽聽 cell.setCellValue("a test");</font> </p> <p> <font face="瀹嬩綋" size="2">聽聽聽 // Write the output to a file</font> </p> <p> <font face="瀹嬩綋" size="2">聽聽聽 FileOutputStream fileOut = new FileOutputStream("workbook.xls");</font> </p> <p> <font face="瀹嬩綋" size="2">聽聽聽 wb.write(fileOut);</font> </p> <p> <font face="瀹嬩綋" size="2">fileOut.close();</font> </p> <p> <font face="瀹嬩綋" size="2">4 錛?鍙弬鑰冩枃妗?/font> </p> <p> <font face="瀹嬩綋" size="2">POI 涓婚〉錛?/font> <a > <font face="瀹嬩綋" size="2">http://jakarta.apache.org/poi/</font> </a> <font face="瀹嬩綋" size="2">錛?/font> </p> <p> <font face="瀹嬩綋" size="2">鍒濆鑰呭浣曞揩閫熶笂鎵嬩嬌鐢≒OI HSSF</font> </p> <p> <a > <font face="瀹嬩綋" size="2">http://jakarta.apache.org/poi/hssf/quick-guide.html</font> </a> <font face="瀹嬩綋" size="2">銆?/font> </p> <p> <font face="瀹嬩綋" size="2">閲岄潰鏈夊緢澶氫緥瀛愪唬鐮侊紝鍙互寰堟柟渚夸笂鎵嬨?/font> </p> <p> <font face="瀹嬩綋" size="2">鍥涳紟浣跨敤蹇冨緱</font> </p> <p> <font face="瀹嬩綋" size="2">POI HSSF 鐨剈sermodel鍖呮妸Excel鏂囦歡鏄犲皠鎴愭垜浠啛鎮夌殑緇撴瀯錛岃濡俉orkbook銆丼heet銆丷ow銆丆ell絳夛紝瀹冩妸鏁翠釜緇撴瀯浠ヤ竴緇勫璞$殑褰㈠紡淇濆瓨鍦ㄥ唴瀛樹箣涓紝渚夸簬鐞嗚В錛屾搷浣滄柟渚匡紝鍩烘湰涓婅兘澶熸弧瓚蟲垜浠殑瑕佹眰錛屾墍浠ヨ榪欎釜涓涓笉閿欑殑閫夋嫨銆?/font> </p> <p> <font color="#000066"> <strong>錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛?br /></strong>鍓嶉潰宸茬粡璁茶繃鍒╃敤POI璇誨啓Excel錛屼笅闈㈡槸涓涓敤POI鍚慐xcel涓彃鍏ュ浘鐗囩殑渚嬪瓙銆?br /><br /></font> <font color="#000066"> <span id="hjtxrfx" class="postbody" twffan="done">瀹樻柟鏂囨。錛?br />Images are part of the drawing support. To add an image just call createPicture() on the drawing patriarch. At the time of writing the following types are supported:<br />PNG<br />JPG<br />DIB<br />It is not currently possible to read existing images and it should be noted that any existing drawings may be erased once you add a image to a sheet.<br /><br />// Create the drawing patriarch. This is the top level container for<br />// all shapes. This will clear out any existing shapes for that sheet.</span> <br /> <br /> </font> <font color="#000066"> <span id="nbvvzxf" class="postbody" twffan="done">閫氳繃HSSFPatriarch綾籧reatePicture鏂規硶鐨勫湪鎸囧畾鐨剋b涓殑sheet鍒涘緩鍥劇墖,瀹冩帴鍙椾簩涓弬鏁幫紝絎竴涓槸HSSFClientAnchor錛岃瀹氬浘鐗囩殑澶у皬銆?br /><br /></span> </font> </p> <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #008080">聽1</span> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <span style="COLOR: #0000ff">package</span> <span style="COLOR: #000000">聽com.poi.hssf.test;<br /></span> <span style="COLOR: #008080">聽2</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <br /> </span> <span style="COLOR: #008080">聽3</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽java.io.FileOutputStream;<br /></span> <span style="COLOR: #008080">聽4</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽java.io.File;<br /></span> <span style="COLOR: #008080">聽5</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽java.io.ByteArrayOutputStream;<br /></span> <span style="COLOR: #008080">聽6</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽java.io.IOException;<br /></span> <span style="COLOR: #008080">聽7</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <br /> </span> <span style="COLOR: #008080">聽8</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽java.awt.image.BufferedImage;<br /></span> <span style="COLOR: #008080">聽9</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽javax.imageio.</span> <span style="COLOR: #000000">*</span> <span style="COLOR: #000000">;<br /></span> <span style="COLOR: #008080">10</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <br /> </span> <span style="COLOR: #008080">11</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽org.apache.poi.hssf.usermodel.HSSFWorkbook;<br /></span> <span style="COLOR: #008080">12</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽org.apache.poi.hssf.usermodel.HSSFSheet;<br /></span> <span style="COLOR: #008080">13</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽org.apache.poi.hssf.usermodel.HSSFPatriarch;<br /></span> <span style="COLOR: #008080">14</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> </span> <span style="COLOR: #0000ff">import</span> <span style="COLOR: #000000">聽org.apache.poi.hssf.usermodel.HSSFClientAnchor;;<br /></span> <span style="COLOR: #008080">15</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/None.gif" align="top" /> <br /> </span> <span style="COLOR: #008080">16</span> <span style="COLOR: #000000"> <img id="Codehighlighter1_440_2605_Open_Image" onclick="this.style.display='none'; Codehighlighter1_440_2605_Open_Text.style.display='none'; Codehighlighter1_440_2605_Closed_Image.style.display='inline'; Codehighlighter1_440_2605_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" /> <img id="Codehighlighter1_440_2605_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_440_2605_Closed_Text.style.display='none'; Codehighlighter1_440_2605_Open_Image.style.display='inline'; Codehighlighter1_440_2605_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" /> </span> <span style="COLOR: #0000ff">public</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">class</span> <span style="COLOR: #000000">聽TestPOI聽</span> <span id="Codehighlighter1_440_2605_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_440_2605_Open_Text"> <span style="COLOR: #000000">{<br /></span> <span style="COLOR: #008080">17</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> <br /> </span> <span style="COLOR: #008080">18</span> <span style="COLOR: #000000"> <img id="Codehighlighter1_486_2603_Open_Image" onclick="this.style.display='none'; Codehighlighter1_486_2603_Open_Text.style.display='none'; Codehighlighter1_486_2603_Closed_Image.style.display='inline'; Codehighlighter1_486_2603_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_486_2603_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_486_2603_Closed_Text.style.display='none'; Codehighlighter1_486_2603_Open_Image.style.display='inline'; Codehighlighter1_486_2603_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽</span> <span style="COLOR: #0000ff">public</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">static</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">void</span> <span style="COLOR: #000000">聽main(String[]聽args)聽</span> <span id="Codehighlighter1_486_2603_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_486_2603_Open_Text"> <span style="COLOR: #000000">{<br /></span> <span style="COLOR: #008080">19</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽FileOutputStream聽fileOut聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">null</span> <span style="COLOR: #000000">;<br /></span> <span style="COLOR: #008080">20</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽BufferedImage聽bufferImg聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #0000ff">null</span> <span style="COLOR: #000000">;<br /></span> <span style="COLOR: #008080">21</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽BufferedImage聽bufferImg1聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">null</span> <span style="COLOR: #000000">;<br /></span> <span style="COLOR: #008080">22</span> <span style="COLOR: #000000"> <img id="Codehighlighter1_636_2010_Open_Image" onclick="this.style.display='none'; Codehighlighter1_636_2010_Open_Text.style.display='none'; Codehighlighter1_636_2010_Closed_Image.style.display='inline'; Codehighlighter1_636_2010_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_636_2010_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_636_2010_Closed_Text.style.display='none'; Codehighlighter1_636_2010_Open_Image.style.display='inline'; Codehighlighter1_636_2010_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">try</span> <span id="Codehighlighter1_636_2010_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_636_2010_Open_Text"> <span style="COLOR: #000000">{<br /></span> <span style="COLOR: #008080">23</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<br /></span> <span style="COLOR: #008080">24</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000">鍏堟妸璇昏繘鏉ョ殑鍥劇墖鏀懼埌涓涓狟yteArrayOutputStream涓紝浠ヤ究浜х敓ByteArray</span> <span style="COLOR: #008000"> <br /> </span> <span style="COLOR: #008080">25</span> <span style="COLOR: #008000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽ByteArrayOutputStream聽byteArrayOut聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">new</span> <span style="COLOR: #000000">聽ByteArrayOutputStream();<br /></span> <span style="COLOR: #008080">26</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽ByteArrayOutputStream聽byteArrayOut1聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">new</span> <span style="COLOR: #000000">聽ByteArrayOutputStream();<br /></span> <span style="COLOR: #008080">27</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽bufferImg聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽ImageIO.read(</span> <span style="COLOR: #0000ff">new</span> <span style="COLOR: #000000">聽File(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">d:/PieChart.jpg</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">));<br /></span> <span style="COLOR: #008080">28</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽bufferImg1聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽ImageIO.read(</span> <span style="COLOR: #0000ff">new</span> <span style="COLOR: #000000">聽File(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">d:/fruitBarChart.jpg</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">));<br /></span> <span style="COLOR: #008080">29</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽ImageIO.write(bufferImg,</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">jpg</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">,byteArrayOut);<br /></span> <span style="COLOR: #008080">30</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽ImageIO.write(bufferImg1,</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">jpg</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">,byteArrayOut1);<br /></span> <span style="COLOR: #008080">31</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽<br /></span> <span style="COLOR: #008080">32</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000">鍒涘緩涓涓伐浣滆杽</span> <span style="COLOR: #008000"> <br /> </span> <span style="COLOR: #008080">33</span> <span style="COLOR: #008000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000">聽聽聽聽聽聽聽聽HSSFWorkbook聽wb聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">new</span> <span style="COLOR: #000000">聽HSSFWorkbook();<br /></span> <span style="COLOR: #008080">34</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽HSSFSheet聽sheet1聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽wb.createSheet(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">new聽sheet</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /></span> <span style="COLOR: #008080">35</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000">HSSFRow聽row聽=聽sheet1.createRow(2);</span> <span style="COLOR: #008000"> <br /> </span> <span style="COLOR: #008080">36</span> <span style="COLOR: #008000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000">聽聽聽聽聽聽聽聽HSSFPatriarch聽patriarch聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽sheet1.createDrawingPatriarch();<br /></span> <span style="COLOR: #008080">37</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽HSSFClientAnchor聽anchor聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">new</span> <span style="COLOR: #000000">聽HSSFClientAnchor(</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">512</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">255</span> <span style="COLOR: #000000">,(</span> <span style="COLOR: #0000ff">short</span> <span style="COLOR: #000000">)聽</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">1</span> <span style="COLOR: #000000">,(</span> <span style="COLOR: #0000ff">short</span> <span style="COLOR: #000000">)</span> <span style="COLOR: #000000">10</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">20</span> <span style="COLOR: #000000">);<br /></span> <span style="COLOR: #008080">38</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽HSSFClientAnchor聽anchor1聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">new</span> <span style="COLOR: #000000">聽HSSFClientAnchor(</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">0</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">512</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">255</span> <span style="COLOR: #000000">,(</span> <span style="COLOR: #0000ff">short</span> <span style="COLOR: #000000">)聽</span> <span style="COLOR: #000000">2</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">30</span> <span style="COLOR: #000000">,(</span> <span style="COLOR: #0000ff">short</span> <span style="COLOR: #000000">)</span> <span style="COLOR: #000000">10</span> <span style="COLOR: #000000">,</span> <span style="COLOR: #000000">60</span> <span style="COLOR: #000000">);<br /></span> <span style="COLOR: #008080">39</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽anchor1.setAnchorType(</span> <span style="COLOR: #000000">2</span> <span style="COLOR: #000000">);<br /></span> <span style="COLOR: #008080">40</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽</span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000">鎻掑叆鍥劇墖</span> <span style="COLOR: #008000"> <br /> </span> <span style="COLOR: #008080">41</span> <span style="COLOR: #008000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000">聽聽聽聽聽聽聽聽patriarch.createPicture(anchor聽,聽wb.addPicture(byteArrayOut.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG));<br /></span> <span style="COLOR: #008080">42</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽patriarch.createPicture(anchor1聽,聽wb.addPicture(byteArrayOut1.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG));<br /></span> <span style="COLOR: #008080">43</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /></span> <span style="COLOR: #008080">44</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽fileOut聽</span> <span style="COLOR: #000000">=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">new</span> <span style="COLOR: #000000">聽FileOutputStream(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">d:/workbook.xls</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">);<br /></span> <span style="COLOR: #008080">45</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000">鍐欏叆excel鏂囦歡</span> <span style="COLOR: #008000"> <br /> </span> <span style="COLOR: #008080">46</span> <span style="COLOR: #008000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽聽聽wb.write(fileOut);<br /></span> <span style="COLOR: #008080">47</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽fileOut.close();<br /></span> <span style="COLOR: #008080">48</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽<br /></span> <span style="COLOR: #008080">49</span> <span style="COLOR: #000000"> <img id="Codehighlighter1_2032_2161_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2032_2161_Open_Text.style.display='none'; Codehighlighter1_2032_2161_Closed_Image.style.display='inline'; Codehighlighter1_2032_2161_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_2032_2161_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2032_2161_Closed_Text.style.display='none'; Codehighlighter1_2032_2161_Open_Image.style.display='inline'; Codehighlighter1_2032_2161_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #0000ff">catch</span> <span style="COLOR: #000000">(IOException聽io)</span> <span id="Codehighlighter1_2032_2161_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_2032_2161_Open_Text"> <span style="COLOR: #000000">{<br /></span> <span style="COLOR: #008080">50</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽io.printStackTrace();<br /></span> <span style="COLOR: #008080">51</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">io聽erorr聽:聽聽</span> <span style="COLOR: #000000">"</span> <span style="COLOR: #000000">+</span> <span style="COLOR: #000000">聽io.getMessage());<br /></span> <span style="COLOR: #008080">52</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">finally</span> <span style="COLOR: #000000"> <br /> </span> <span style="COLOR: #008080">53</span> <span style="COLOR: #000000"> <img id="Codehighlighter1_2183_2597_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2183_2597_Open_Text.style.display='none'; Codehighlighter1_2183_2597_Closed_Image.style.display='inline'; Codehighlighter1_2183_2597_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_2183_2597_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2183_2597_Closed_Text.style.display='none'; Codehighlighter1_2183_2597_Open_Image.style.display='inline'; Codehighlighter1_2183_2597_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span id="Codehighlighter1_2183_2597_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_2183_2597_Open_Text"> <span style="COLOR: #000000">{<br /></span> <span style="COLOR: #008080">54</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">if</span> <span style="COLOR: #000000">聽(fileOut聽</span> <span style="COLOR: #000000">!=</span> <span style="COLOR: #000000">聽</span> <span style="COLOR: #0000ff">null</span> <span style="COLOR: #000000">)<br /></span> <span style="COLOR: #008080">55</span> <span style="COLOR: #000000"> <img id="Codehighlighter1_2238_2583_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2238_2583_Open_Text.style.display='none'; Codehighlighter1_2238_2583_Closed_Image.style.display='inline'; Codehighlighter1_2238_2583_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_2238_2583_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2238_2583_Closed_Text.style.display='none'; Codehighlighter1_2238_2583_Open_Image.style.display='inline'; Codehighlighter1_2238_2583_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span> <span id="Codehighlighter1_2238_2583_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_2238_2583_Open_Text"> <span style="COLOR: #000000">{<br /></span> <span style="COLOR: #008080">56</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<br /></span> <span style="COLOR: #008080">57</span> <span style="COLOR: #000000"> <img id="Codehighlighter1_2292_2366_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2292_2366_Open_Text.style.display='none'; Codehighlighter1_2292_2366_Closed_Image.style.display='inline'; Codehighlighter1_2292_2366_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_2292_2366_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2292_2366_Closed_Text.style.display='none'; Codehighlighter1_2292_2366_Open_Image.style.display='inline'; Codehighlighter1_2292_2366_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">try</span> <span style="COLOR: #000000">聽</span> <span id="Codehighlighter1_2292_2366_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_2292_2366_Open_Text"> <span style="COLOR: #000000">{<br /></span> <span style="COLOR: #008080">58</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽fileOut.close();<br /></span> <span style="COLOR: #008080">59</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> </span> <span style="COLOR: #008080">60</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #0000ff">catch</span> <span style="COLOR: #000000">聽(IOException聽e)<br /></span> <span style="COLOR: #008080">61</span> <span style="COLOR: #000000"> <img id="Codehighlighter1_2430_2565_Open_Image" onclick="this.style.display='none'; Codehighlighter1_2430_2565_Open_Text.style.display='none'; Codehighlighter1_2430_2565_Closed_Image.style.display='inline'; Codehighlighter1_2430_2565_Closed_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /> <img id="Codehighlighter1_2430_2565_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_2430_2565_Closed_Text.style.display='none'; Codehighlighter1_2430_2565_Open_Image.style.display='inline'; Codehighlighter1_2430_2565_Open_Text.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span> <span id="Codehighlighter1_2430_2565_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"> <img src="http://m.tkk7.com/images/dot.gif" /> </span> <span id="Codehighlighter1_2430_2565_Open_Text"> <span style="COLOR: #000000">{<br /></span> <span style="COLOR: #008080">62</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="COLOR: #008000">//</span> <span style="COLOR: #008000">聽TODO聽Auto-generated聽catch聽block</span> <span style="COLOR: #008000"> <br /> </span> <span style="COLOR: #008080">63</span> <span style="COLOR: #008000"> <img src="http://m.tkk7.com/images/OutliningIndicators/InBlock.gif" align="top" /> </span> <span style="COLOR: #000000">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽e.printStackTrace();<br /></span> <span style="COLOR: #008080">64</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> </span> <span style="COLOR: #008080">65</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> </span> <span style="COLOR: #008080">66</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽聽聽聽聽聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> </span> <span style="COLOR: #008080">67</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />聽聽聽聽}</span> </span> <span style="COLOR: #000000"> <br /> </span> <span style="COLOR: #008080">68</span> <span style="COLOR: #000000"> <img src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span> </span> </div> <img src ="http://m.tkk7.com/czcode/aggbug/88448.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/czcode/" target="_blank">宕旀尟</a> 2006-12-18 10:35 <a href="http://m.tkk7.com/czcode/archive/2006/12/18/88448.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鐢↗ava鍔ㄦ佷唬鐞嗗疄鐜癆OP http://m.tkk7.com/czcode/archive/2006/12/13/87433.html宕旀尟宕旀尟Wed, 13 Dec 2006 03:43:00 GMThttp://m.tkk7.com/czcode/archive/2006/12/13/87433.htmlhttp://m.tkk7.com/czcode/comments/87433.htmlhttp://m.tkk7.com/czcode/archive/2006/12/13/87433.html#Feedback0http://m.tkk7.com/czcode/comments/commentRss/87433.htmlhttp://m.tkk7.com/czcode/services/trackbacks/87433.html鐩墠鏁翠釜寮鍙戠ぞ鍖哄AOP(Aspect Oriented Programing)鎺ㄥ磭澶囪嚦錛屼篃娑岀幇鍑哄ぇ閲忔敮鎸丄OP鐨勪紭縐Framework,--Spring, JAC, Jboss AOP 絳夌瓑銆侫OP浼間箮涓鏃朵箣闂存垚浜嗘疆嫻併侸ava鍒濆鑰呬笉紱佽鍙戝嚭鎰熸叏錛孫OP榪樻病鏈夊閫氬憿錛屽張鏉OP銆傛湰鏂囦笉鏄鍦ㄧ悊璁轟笂鍏蜂綋闃愯堪浣曚負AOP, 涓轟綍瑕佽繘琛孉OP . 瑕佽緇嗕簡瑙e涔燗OP鍙互鍒板畠鑰佸http://aosd.net鍘葷灖鐬с傝繖閲屽彧鏄剰鍥鵑氳繃涓涓畝鍗曠殑渚嬪瓙鍚戝垵瀛﹁呭睍紺轟竴涓嬪浣曟潵榪涜AOP.

銆銆涓轟簡綆鍗曡搗瑙侊紝渚嬪瓙娌℃湁娌℃湁浣跨敤浠諱綍絎笁鏂圭殑AOP Framework, 鑰屾槸鍒╃敤Java璇█鏈韓鑷甫鐨勫姩鎬佷唬鐞嗗姛鑳芥潵瀹炵幇AOP.

銆銆璁╂垜浠厛鍥炲埌AOP鏈韓錛孉OP涓昏搴旂敤浜庢棩蹇楄褰曪紝鎬ц兘緇熻錛屽畨鍏ㄦ帶鍒?浜嬪姟澶勭悊絳夋柟闈€傚畠鐨勪富瑕佹剰鍥懼氨瑕佸皢鏃ュ織璁板綍錛屾ц兘緇熻錛屽畨鍏ㄦ帶鍒剁瓑絳変唬鐮佷粠鍟嗕笟閫昏緫浠g爜涓竻妤氱殑鍒掑垎鍑烘潵錛屾垜浠彲浠ユ妸榪欎簺琛屼負涓涓竴涓崟鐙湅浣滅郴緇熸墍瑕佽В鍐崇殑闂錛屽氨鏄墍璋撶殑闈㈠悜闂鐨勭紪紼?涓嶇煡灝咥OP璇戜綔闈㈠悜闂鐨勭紪紼嬫槸鍚︽瑺濡?銆傞氳繃瀵硅繖浜涜涓虹殑鍒嗙錛屾垜浠笇鏈涘彲浠ュ皢瀹冧滑鐙珛鍦伴厤緗埌鍟嗕笟鏂規硶涓紝鑰岃鏀瑰彉榪欎簺琛屼負涔熶笉闇瑕佸獎鍝嶅埌鍟嗕笟鏂規硶浠g爜銆?

銆銆鍋囪緋葷粺鐢變竴緋誨垪鐨凚usinessObject鎵瀹屾垚涓氬姟閫昏緫鍔熻兘錛岀郴緇熻姹傚湪姣忎竴嬈′笟鍔¢昏緫澶勭悊鏃惰鍋氭棩蹇楄褰曘傝繖閲屾垜浠暐鍘誨叿浣撶殑涓氬姟閫昏緫浠g爜銆?

public interface BusinessInterface {
銆public void processBusiness();
}

public class BusinessObject implements BusinessInterface {
銆private Logger logger = Logger.getLogger(this.getClass().getName());
銆public void processBusiness(){
銆銆try {
銆銆銆logger.info("start to processing...");
銆銆銆//business logic here.
銆銆銆System.out.println(鈥渉ere is business logic鈥?;
銆銆銆logger.info("end processing...");
銆銆} catch (Exception e){
銆銆銆logger.info("exception happends...");
銆銆銆//exception handling
銆銆}
銆}
}
銆銆榪欓噷澶勭悊鍟嗕笟閫昏緫鐨勪唬鐮佸拰鏃ュ織璁板綍浠g爜娣峰悎鍦ㄤ竴璧鳳紝榪欑粰鏃ュ悗鐨勭淮鎶ゅ甫鏉ヤ竴瀹氱殑鍥伴毦錛屽茍涓斾篃浼氶犳垚澶ч噺鐨勪唬鐮侀噸澶嶃傚畬鍏ㄧ浉鍚岀殑log浠g爜灝嗗嚭鐜板湪緋葷粺鐨勬瘡涓涓狟usinessObject涓?

銆銆鎸夌収AOP鐨勬濇兂錛屾垜浠簲璇ユ妸鏃ュ織璁板綍浠g爜鍒嗙鍑烘潵銆傝灝嗚繖浜涗唬鐮佸垎紱誨氨娑夊強鍒頒竴涓棶棰橈紝鎴戜滑蹇呴』鐭ラ亾鍟嗕笟閫昏緫浠g爜浣曟椂琚皟鐢紝榪欐牱鎴戜滑濂芥彃鍏ユ棩蹇楄褰曚唬鐮併備竴鑸潵璇磋鎴幏涓涓柟娉曪紝鎴戜滑鍙互閲囩敤鍥炶皟鏂規硶鎴栬呭姩鎬佷唬鐞嗐傚姩鎬佷唬鐞嗕竴鑸鏇村姞鐏墊椿涓浜涳紝鐩墠澶氭暟鐨凙OP Framework涔熷ぇ閮介噰鐢ㄤ簡鍔ㄦ佷唬鐞嗘潵瀹炵幇銆傝繖閲屾垜浠篃閲囩敤鍔ㄦ佷唬鐞嗕綔涓轟緥瀛愩?

銆銆JDK1.2浠ュ悗鎻愪緵浜嗗姩鎬佷唬鐞嗙殑鏀寔錛岀▼搴忓憳閫氳繃瀹炵幇java.lang.reflect.InvocationHandler鎺ュ彛鎻愪緵涓涓墽琛屽鐞嗗櫒錛岀劧鍚庨氳繃java.lang.reflect.Proxy寰楀埌涓涓唬鐞嗗璞★紝閫氳繃榪欎釜浠g悊瀵硅薄鏉ユ墽琛屽晢涓氭柟娉?鍦ㄥ晢涓氭柟娉曡璋冪敤鐨勫悓鏃訛紝鎵ц澶勭悊鍣ㄤ細琚嚜鍔ㄨ皟鐢ㄣ?

銆銆鏈変簡JDK鐨勮繖縐嶆敮鎸侊紝鎴戜滑鎵瑕佸仛鐨勪粎浠呮槸鎻愪緵涓涓棩蹇楀鐞嗗櫒銆?

public class LogHandler implements InvocationHandler {

銆private Logger logger 錛?Logger.getLogger(this.getClass().getName());
銆銆private Object delegate;
銆銆public LogHandler(Object delegate){
銆銆銆this.delegate = delegate;
銆銆}

銆public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
銆銆Object o = null;
銆銆try {
銆銆銆logger.info("method stats..." 錛?method);
銆銆銆o = method.invoke(delegate,args);
銆銆銆logger.info("method ends..." + method);
銆銆} catch (Exception e){
銆銆銆logger.info("Exception happends...");
銆銆銆//excetpion handling.
銆銆}
銆銆return o;
銆}
}
銆銆鐜板湪鎴戜滑鍙互鎶夿usinessObject閲岄潰鐨勬墍鏈夋棩蹇楀鐞嗕唬鐮佸叏閮ㄥ幓鎺変簡銆?

public class BusinessObject implements BusinessInterface {

銆private Logger logger = Logger.getLogger(this.getClass().getName());
銆public void processBusiness(){
銆銆//business processing
銆銆System.out.println(鈥渉ere is business logic鈥?;
銆}
}
銆銆瀹㈡埛绔皟鐢ㄥ晢涓氭柟娉曠殑浠g爜濡備笅錛?br />
BusinessInterface businessImp = new BusinessObject();

InvocationHandler handler = new LogHandler(businessImp);

BusinessInterface proxy = (BusinessInterface) Proxy.newProxyInstance(
銆businessImp.getClass().getClassLoader(),
銆businessImp.getClass().getInterfaces(),
銆handler);

proxy.processBusiness();
銆銆紼嬪簭杈撳嚭濡備笅錛?

INFO: method stats...
here is business logic
INFO: method ends...
銆銆鑷蟲鎴戜滑鐨勭涓嬈″皬灝濊瘯綆楁槸瀹屾垚浜嗐傚彲浠ョ湅鍒幫紝閲囩敤AOP涔嬪悗錛屾棩蹇楄褰曞拰涓氬姟閫昏緫浠g爜瀹屽叏鍒嗗紑浜嗭紝浠ュ悗瑕佹敼鍙樻棩蹇楄褰曠殑璇濆彧闇瑕佷慨鏀規棩蹇楄褰曞鐞嗗櫒灝辮浜嗭紝鑰屼笟鍔″璞℃湰韜紙BusinessObject錛夋棤闇鍋氫換浣曚慨鏀廣傚茍涓旇繖涓棩蹇楄褰曚笉浼氶犳垚閲嶅浠g爜浜嗭紝鎵鏈夌殑鍟嗕笟澶勭悊瀵硅薄閮藉彲浠ラ噸鐢ㄨ繖涓棩蹇楀鐞嗗櫒銆?

銆銆褰撶劧鍦ㄥ疄闄呭簲鐢ㄤ腑錛岃繖涓緥瀛愬氨鏄懼緱澶矖緋欎簡銆傜敱浜嶫DK鐨勫姩鎬佷唬鐞嗗茍娌℃湁鐩存帴鏀寔涓嬈℃敞鍐屽涓狪nvocationHandler錛岄偅涔堟垜浠涓氬姟澶勭悊鏂規硶鏃㈣鏃ュ織璁板綍鍙堣鎬ц兘緇熻鏃訛紝灝遍渶瑕佽嚜宸卞仛涓浜涘彉閫氫簡銆備竴鑸垜浠彲浠ヨ嚜宸卞畾涔変竴涓狧andler鎺ュ彛錛岀劧鍚庣淮鎶や竴涓槦鍒楀瓨鏀炬墍鏈塇andler, 褰揑nvocationHandler琚Е鍙戠殑鏃跺欐垜浠緷嬈¤皟鐢ㄨ嚜宸辯殑Handler銆傛墍騫哥殑鏄洰鍓嶅嚑涔庢墍鏈夌殑AOP Framework閮藉榪欐柟闈㈡彁渚涗簡寰堝ソ鐨勬敮鎸?榪欓噷鎺ㄨ崘澶у浣跨敤Spring銆?br />



宕旀尟 2006-12-13 11:43 鍙戣〃璇勮
]]>
鐢↗S鐨勫歡鏃?/title><link>http://m.tkk7.com/czcode/archive/2006/12/06/85839.html</link><dc:creator>宕旀尟</dc:creator><author>宕旀尟</author><pubDate>Wed, 06 Dec 2006 06:22:00 GMT</pubDate><guid>http://m.tkk7.com/czcode/archive/2006/12/06/85839.html</guid><wfw:comment>http://m.tkk7.com/czcode/comments/85839.html</wfw:comment><comments>http://m.tkk7.com/czcode/archive/2006/12/06/85839.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/czcode/comments/commentRss/85839.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/czcode/services/trackbacks/85839.html</trackback:ping><description><![CDATA[ <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"> <span style="COLOR: #008080">聽1</span>聽<span style="COLOR: #000000"><</span><span style="COLOR: #000000">script</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #008080">聽2</span>聽<span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000">聽start</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">聽3</span>聽<span style="COLOR: #000000"></span><span style="COLOR: #0000ff">var</span><span style="COLOR: #000000">聽n;<br /></span><span style="COLOR: #008080">聽4</span>聽<span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">聽init(){<br /></span><span style="COLOR: #008080">聽5</span>聽<span style="COLOR: #000000">聽聽start</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">聽6</span>聽<span style="COLOR: #000000">聽聽}<br /></span><span style="COLOR: #008080">聽7</span>聽<span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">function</span><span style="COLOR: #000000">聽process(i){<br /></span><span style="COLOR: #008080">聽8</span>聽<span style="COLOR: #000000">聽聽n</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">setTimeout(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">init()</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000">);<br /></span><span style="COLOR: #008080">聽9</span>聽<span style="COLOR: #000000">聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(start</span><span style="COLOR: #000000">></span><span style="COLOR: #000000">i){<br /></span><span style="COLOR: #008080">10</span>聽<span style="COLOR: #000000">聽聽聽clearTimeout(n);<br /></span><span style="COLOR: #008080">11</span>聽<span style="COLOR: #000000">聽聽聽聽start</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #008080">12</span>聽<span style="COLOR: #000000"></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">榪欓噷鍐欎綘闇瑕佹墽琛岀殑浠g爜</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #008080">13</span>聽<span style="COLOR: #008000"></span><span style="COLOR: #000000">聽聽}<br /></span><span style="COLOR: #008080">14</span>聽<span style="COLOR: #000000">}<br /></span><span style="COLOR: #008080">15</span>聽<span style="COLOR: #000000"></span><span style="COLOR: #000000"></</span><span style="COLOR: #000000">script</span><span style="COLOR: #000000">></span></div>鍏朵腑process(i) i涓轟綘瑕佽緗歡榪熺殑鏃墮棿 縐掍負鍗曚綅 <br />鍏充簬timeout:<br />瀹冨叾瀹炲氨鏄竴涓驚鐜屽凡錛屽湪寰幆閲岃皟鐢ㄥ畠鐨勭涓涓弬鏁幫紝絎?涓弬鏁版槸Thread.sleep鐨勬椂闂撮棿闅旓紝褰撶劧濡傛灉浣犱笉鍦ㄥ悎閫傜殑鏃跺檆learTimeout鐨勮瘽錛屽畠灝嗘垚涓轟竴涓寰幆 <img src ="http://m.tkk7.com/czcode/aggbug/85839.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/czcode/" target="_blank">宕旀尟</a> 2006-12-06 14:22 <a href="http://m.tkk7.com/czcode/archive/2006/12/06/85839.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://linmh.com" target="_blank">美女黄色免费网站</a>| <a href="http://fantoment.com" target="_blank">亚洲天堂福利视频</a>| <a href="http://caoliusq1024.com" target="_blank">18禁止观看免费私人影院</a>| <a href="http://juguanghr.com" target="_blank">免费v片在线观看</a>| <a href="http://lzlcp.com" target="_blank">四虎免费影院ww4164h</a>| <a href="http://www-6209.com" target="_blank">亚洲 暴爽 AV人人爽日日碰</a>| <a href="http://v1s3u5.com" target="_blank">最近的免费中文字幕视频</a>| <a href="http://www52a.com" target="_blank">亚洲最大中文字幕无码网站</a>| <a href="http://blcvs.com" target="_blank">亚洲AV无码国产精品麻豆天美</a>| <a href="http://h47h.com" target="_blank">日韩免费在线观看视频</a>| <a href="http://scjcled.com" target="_blank">亚洲成人黄色在线</a>| <a href="http://ittenyear.com" target="_blank">亚洲国产成人一区二区精品区</a>| <a href="http://51porn3.com" target="_blank">精品一区二区三区无码免费视频</a>| <a href="http://41xjj.com" target="_blank">久久久国产亚洲精品</a>| <a href="http://8x6c.com" target="_blank">亚洲综合无码一区二区三区</a>| <a href="http://hyhtzh.com" target="_blank">国产国产成年年人免费看片</a>| <a href="http://lshwork.com" target="_blank">在线视频观看免费视频18</a>| <a href="http://gdbobo.com" target="_blank">国产成人亚洲毛片</a>| <a href="http://116qc.com" target="_blank">免费无码一区二区三区蜜桃大</a>| <a href="http://9v9av.com" target="_blank">亚洲AV成人片色在线观看</a>| <a href="http://av520av.com" target="_blank">亚洲熟女精品中文字幕</a>| <a href="http://ygloka.com" target="_blank">亚洲精品午夜在线观看</a>| <a href="http://5079157.com" target="_blank">亚洲电影国产一区</a>| <a href="http://xianzznn.com" target="_blank">国产成A人亚洲精V品无码</a>| <a href="http://hlyidc.com" target="_blank">亚洲国产精品成人AV无码久久综合影院 </a>| <a href="http://miya863.com" target="_blank">亚洲精品V欧洲精品V日韩精品</a>| <a href="http://okgou58.com" target="_blank">亚洲伊人久久大香线蕉在观</a>| <a href="http://516698.com" target="_blank">亚洲熟妇无码AV在线播放</a>| <a href="http://bd0574.com" target="_blank">一区二区在线免费观看</a>| <a href="http://nnlxl.com" target="_blank">国产精品美女免费视频观看</a>| <a href="http://qnyjny.com" target="_blank">亚洲日韩在线视频</a>| <a href="http://gzmcmy.com" target="_blank">亚洲中文字幕无码久久2017</a>| <a href="http://155lh.com" target="_blank">亚洲精品尤物yw在线影院</a>| <a href="http://xsjxp.com" target="_blank">亚洲伊人久久大香线蕉影院</a>| <a href="http://wdjiuye.com" target="_blank">亚洲AV成人无码久久精品老人</a>| <a href="http://littlevv.com" target="_blank">亚洲精品视频免费</a>| <a href="http://www330330.com" target="_blank">国产区卡一卡二卡三乱码免费</a>| <a href="http://www2019rz.com" target="_blank">国产麻豆一精品一AV一免费</a>| <a href="http://wwwzs88.com" target="_blank">精品在线免费视频</a>| <a href="http://taobaohuopin.com" target="_blank">亚洲午夜一区二区三区</a>| <a href="http://477077.com" target="_blank">亚洲国产高清精品线久久</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>