锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品夜夜夜妓女网,亚洲成AⅤ人影院在线观看,久久亚洲中文无码咪咪爱http://m.tkk7.com/WshmAndLily/category/20697.htmlzh-cnMon, 31 Dec 2007 01:49:31 GMTMon, 31 Dec 2007 01:49:31 GMT60Quartz鐨刢ron琛ㄨ揪寮?/title><link>http://m.tkk7.com/WshmAndLily/articles/171333.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Fri, 28 Dec 2007 14:07:00 GMT</pubDate><guid>http://m.tkk7.com/WshmAndLily/articles/171333.html</guid><wfw:comment>http://m.tkk7.com/WshmAndLily/comments/171333.html</wfw:comment><comments>http://m.tkk7.com/WshmAndLily/articles/171333.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/WshmAndLily/comments/commentRss/171333.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/WshmAndLily/services/trackbacks/171333.html</trackback:ping><description><![CDATA[涓涓猚ron琛ㄨ揪寮忔湁鑷沖皯6涓紙涔熷彲鑳?涓級(jí)鏈夌┖鏍煎垎闅旂殑鏃墮棿鍏冪礌銆?br /> <font size="2"></font> <h4 class="TextColor1" style="margin-bottom: 0px"><font size="2">鎸夐『搴忎緷嬈′負(fù)</font> </h4> <h4 class="TextColor1" style="margin-bottom: 0px"><font size="2">縐掞紙0~59錛?/font> </h4> <div class="rxvvbtd" id="msgcns!FEB4FAFDF8FBDF68!105"> <p><font size="2">鍒嗛挓錛?~59錛?/font> </p> <p><font size="2">灝忔椂錛?~23錛?/font> </p> <p><font size="2">澶╋紙鏈堬級(jí)錛?~31錛屼絾鏄綘闇瑕佽冭檻浣犳湀鐨勫ぉ鏁幫級(jí)</font> </p> <p><font size="2">鏈堬紙0~11錛?/font> </p> <p><font size="2">澶╋紙鏄熸湡錛夛紙1~7 1=SUN 鎴?SUN錛孧ON錛孴UE錛學(xué)ED錛孴HU錛孎RI錛孲AT錛?/font> </p> <p><font size="2">7.騫翠喚錛?970錛?099錛?br /> <br /> <font color="#000000">鍏朵腑姣忎釜鍏冪礌鍙互鏄竴涓?濡?),涓涓繛緇尯闂?9-12),涓涓棿闅旀椂闂?8-18/4)(/琛ㄧず姣忛殧4灝忔椂),涓涓垪琛?1,3,5),閫氶厤絎︺傜敱浜?鏈堜喚涓殑鏃ユ湡"鍜?鏄熸湡涓殑鏃ユ湡"榪欎袱涓厓绱犱簰鏂ョ殑,蹇呴』瑕佸鍏朵腑涓涓緗?.</font></font> </p> <p><font size="2">0 0 10,14,16 * * ? 姣忓ぉ涓婂崍10鐐癸紝涓嬪崍2鐐癸紝4鐐?br /> 0 0/30 9-17 * * ??? 鏈濅節(jié)鏅氫簲宸ヤ綔鏃墮棿鍐呮瘡鍗婂皬鏃?br /> </font><font size="2">0 0 12 ? * WED 琛ㄧず姣忎釜鏄熸湡涓変腑鍗?2鐐?/font> </p> <p><font size="2">鏈変簺瀛愯〃杈懼紡鑳藉寘鍚竴浜涜寖鍥存垨鍒楄〃</font> </p> <p><font size="2">渚嬪錛氬瓙琛ㄨ揪寮忥紙<strong>澶╋紙鏄熸湡錛?/strong>錛夊彲浠ヤ負(fù) “MON-FRI”錛?#8220;MON錛學(xué)ED錛孎RI”錛?#8220;MON-WED,SAT”</font> </p> <p><font size="2">“*”瀛楃浠h〃鎵鏈夊彲鑳界殑鍊?/font> </p> <p><font size="2">鍥犳錛?#8220;*”鍦ㄥ瓙琛ㄨ揪寮忥紙<strong>鏈?/strong>錛夐噷琛ㄧず姣忎釜鏈堢殑鍚箟錛?#8220;*”鍦ㄥ瓙琛ㄨ揪寮忥紙<strong>澶╋紙鏄熸湡錛?/strong>錛夎〃紺烘槦鏈熺殑姣忎竴澶?/font> </p> <p><font size="2"></font>?</p> <p><font size="2">“/”瀛楃鐢ㄦ潵鎸囧畾鏁板肩殑澧為噺</font> </p> <p><font size="2">渚嬪錛氬湪瀛愯〃杈懼紡錛堝垎閽燂級(jí)閲岀殑“0/15”琛ㄧず浠庣0鍒嗛挓寮濮嬶紝姣?5鍒嗛挓</font> </p> <p><font size="2">?????? ? 鍦ㄥ瓙琛ㄨ揪寮忥紙鍒嗛挓錛夐噷鐨?#8220;3/20”琛ㄧず浠庣3鍒嗛挓寮濮嬶紝姣?0鍒嗛挓錛堝畠鍜?#8220;3錛?3錛?3”錛夌殑鍚箟涓鏍?/font> </p> <p><font size="2"><br /> “錛?#8221;瀛楃浠呰鐢ㄤ簬澶╋紙鏈堬級(jí)鍜屽ぉ錛堟槦鏈燂級(jí)涓や釜瀛愯〃杈懼紡錛岃〃紺轟笉鎸囧畾鍊?/font> </p> <p><font size="2">褰?涓瓙琛ㄨ揪寮忓叾涓箣涓琚寚瀹氫簡(jiǎn)鍊間互鍚庯紝涓轟簡(jiǎn)閬垮厤鍐茬獊錛岄渶瑕佸皢鍙︿竴涓瓙琛ㄨ揪寮忕殑鍊艱涓?#8220;錛?#8221;</font> </p> <p><font size="2"></font>?</p> <p><font size="2">“L” 瀛楃浠呰鐢ㄤ簬澶╋紙鏈堬級(jí)鍜屽ぉ錛堟槦鏈燂級(jí)涓や釜瀛愯〃杈懼紡錛屽畠鏄崟璇?#8220;last”鐨勭緝鍐?/font> </p> <p><font size="2">浣嗘槸瀹冨湪涓や釜瀛愯〃杈懼紡閲岀殑鍚箟鏄笉鍚岀殑銆?/font> </p> <p><font size="2">鍦ㄥぉ錛堟湀錛夊瓙琛ㄨ揪寮忎腑錛?#8220;L”琛ㄧず涓涓湀鐨勬渶鍚庝竴澶?/font> </p> <p><font size="2">鍦ㄥぉ錛堟槦鏈燂級(jí)鑷〃杈懼紡涓紝“L”琛ㄧず涓涓槦鏈熺殑鏈鍚庝竴澶╋紝涔熷氨鏄疭AT</font> </p> <p><font size="2">濡傛灉鍦?#8220;L”鍓嶆湁鍏蜂綋鐨勫唴瀹癸紝瀹冨氨鍏鋒湁鍏朵粬鐨勫惈涔変簡(jiǎn)</font> </p> <p><font size="2">渚嬪錛?#8220;6L”琛ㄧず榪欎釜鏈堢殑鍊掓暟絎紪澶╋紝“錛︼疾錛╋棘”琛ㄧず榪欎釜鏈堢殑鏈涓涓槦鏈熶簲</font> </p> <p><font size="2">娉ㄦ剰錛氬湪浣跨敤“L”鍙傛暟鏃訛紝涓嶈鎸囧畾鍒楄〃鎴栬寖鍥達(dá)紝鍥犱負(fù)榪欎細(xì)瀵艱嚧闂</font> </p> </div> <img src ="http://m.tkk7.com/WshmAndLily/aggbug/171333.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/WshmAndLily/" target="_blank">semovy</a> 2007-12-28 22:07 <a href="http://m.tkk7.com/WshmAndLily/articles/171333.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Quartz 鍦⊿pring涓姩鎬佽緗甤ronExpressionhttp://m.tkk7.com/WshmAndLily/articles/145634.htmlsemovysemovySun, 16 Sep 2007 13:36:00 GMThttp://m.tkk7.com/WshmAndLily/articles/145634.htmlhttp://m.tkk7.com/WshmAndLily/comments/145634.htmlhttp://m.tkk7.com/WshmAndLily/articles/145634.html#Feedback0http://m.tkk7.com/WshmAndLily/comments/commentRss/145634.htmlhttp://m.tkk7.com/WshmAndLily/services/trackbacks/145634.html闃呰鍏ㄦ枃

semovy 2007-09-16 21:36 鍙戣〃璇勮
]]>
Open Session In Viewhttp://m.tkk7.com/WshmAndLily/articles/143817.htmlsemovysemovySun, 09 Sep 2007 10:15:00 GMThttp://m.tkk7.com/WshmAndLily/articles/143817.htmlhttp://m.tkk7.com/WshmAndLily/comments/143817.htmlhttp://m.tkk7.com/WshmAndLily/articles/143817.html#Feedback0http://m.tkk7.com/WshmAndLily/comments/commentRss/143817.htmlhttp://m.tkk7.com/WshmAndLily/services/trackbacks/143817.html鍦ㄦ病鏈変嬌鐢?/font>Spring鎻愪緵鐨?/span>Open Session In View鎯呭喌涓嬶紝鍥犻渶瑕佸湪service(or Dao)灞傞噷鎶?/span>session鍏抽棴錛屾墍浠?/span>lazy loading 涓?/span>true鐨勮瘽錛岃鍦ㄥ簲鐢ㄥ眰鍐呮妸鍏崇郴闆嗗悎閮藉垵濮嬪寲錛屽 company.getEmployees()錛屽惁鍒?/span>Hibernate鎶?/span>session already closed Exception;    Open Session In View鎻愪緵浜?jiǎn)涓縐嶇畝渚跨殑鏂規(guī)硶錛岃緝濂藉湴瑙e喅浜?/span>lazy loading闂.

    瀹冩湁涓ょ閰嶇疆鏂瑰紡OpenSessionInViewInterceptor鍜?span style="font-size: 10pt; color: #4b4b4b; font-family: Verdana">OpenSessionInViewFilter(鍏蜂綋鍙傜湅SpringSide)錛屽姛鑳界浉鍚岋紝鍙槸涓涓湪web.xml閰嶇疆錛屽彟涓涓湪application.xml閰嶇疆鑰屽凡銆?/span>

    Open Session In View鍦?/span>request鎶?/span>session緇戝畾鍒板綋鍓?/span>thread鏈熼棿涓鐩翠繚鎸?/span>hibernate session鍦?/span>open鐘舵侊紝浣?/span>session鍦?/span>request鐨勬暣涓湡闂撮兘鍙互浣跨敤錛屽鍦?/span>View灞傞噷PO涔熷彲浠?/span>lazy loading鏁版嵁錛屽 ${ company.employees }銆傚綋View 灞傞昏緫瀹屾垚鍚庯紝鎵嶄細(xì)閫氳繃Filter鐨?/span>doFilter鏂規(guī)硶鎴?/span>Interceptor鐨?/span>postHandle鏂規(guī)硶鑷姩鍏抽棴session銆?/span> 

OpenSessionInViewInterceptor閰嶇疆

<beans>
   
<bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
         
<property name="sessionFactory">
         
<ref bean="sessionFactory"/>
    
</property>
   
</bean>
   
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
       
<property name="interceptors">
         
<list>
            
<ref bean="openSessionInViewInterceptor"/>
       
</list>
     
</property>
     
<property name="mappings">
     ... 
    
</property>
   
</bean> ...
</beans> 

OpenSessionInViewFilter閰嶇疆

<web-app>
 ... 
  
<filter>
     
<filter-name>hibernateFilter</filter-name>
     
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class>
     
<!-- singleSession榛樿涓簍rue,鑻ヨ涓篺alse鍒欑瓑浜庢病鐢∣penSessionInView -->
    
<init-param>
       
<param-name>singleSession</param-name>
       
<param-value>true</param-value>
    
</init-param>
  
</filter>
 ... 
  
<filter-mapping>
     
<filter-name>hibernateFilter</filter-name>
     
<url-pattern>*.do</url-pattern>
   
</filter-mapping>
 ... 
</web-app> 

寰堝浜哄湪浣跨敤OpenSessionInView榪囩▼涓彁鍙?qiáng)涓涓敊璇細(xì)

org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition 

鐪嬬湅OpenSessionInViewFilter閲岀殑opensession鏂規(guī)硶

protected Session openSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException {
    Session session 
= SessionFactoryUtils.getSession(sessionFactory, true);
    session.setFlushMode(FlushMode.NEVER);
    
return session;
}

    鍙互鐪嬪埌OpenSessionInViewFilter鍦╣etSession鐨勬椂鍊?浼?xì)鎶婅幏鍙栧洖鏉ョ殑session鐨刦lush mode 璁句負(fù)FlushMode.NEVER銆傜劧鍚庢妸璇essionFactory緇戝畾鍒癟ransactionSynchronizationManager錛屼嬌request鐨勬暣涓繃紼嬮兘浣跨敤鍚屼竴涓猻ession錛屽湪璇鋒眰榪囧悗鍐嶆帴闄よsessionFactory鐨勭粦瀹氾紝鏈鍚?span class="me1">closeSessionIfNecessary鏍規(guī)嵁璇ession鏄惁宸插拰transaction緇戝畾鏉ュ喅瀹氭槸鍚﹀叧闂璼ession銆傚湪榪欎釜榪囩▼涓紝鑻ibernateTemplate 鍙戠幇鑷綋鍓峴ession鏈変笉鏄痳eadOnly鐨則ransaction錛屽氨浼?xì)鑾峰彇鍒癋lushMode.AUTO Session錛屼嬌鏂規(guī)硶鎷ユ湁鍐欐潈闄愩?/p>

    涔熷嵆鏄紝濡傛灉鏈変笉鏄痳eadOnly鐨則ransaction灝卞彲浠ョ敱Flush.NEVER杞負(fù)Flush.AUTO,鎷ユ湁insert,update,delete鎿嶄綔鏉冮檺錛屽鏋滄病鏈塼ransaction錛屽茍涓旀病鏈夊彟澶栦漢涓哄湴璁緁lush model鐨勮瘽錛屽垯doFilter鐨勬暣涓繃紼嬮兘鏄疐lush.NEVER銆傛墍浠ュ彈transaction淇濇姢鐨勬柟娉曟湁鍐欐潈闄愶紝娌″彈淇濇姢鐨勫垯娌℃湁銆?/p>

閲囩敤spring鐨勪簨鍔″0鏄?浣挎柟娉曞彈transaction鎺у埗

    <bean id="baseTransaction" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"       abstract="true">
         
<property name="transactionManager" ref="transactionManager"/>
         
<property name="proxyTargetClass" value="true"/>
         
<property name="transactionAttributes">
             
<props>
                 
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                 
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                 
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
                 
<prop key="save*">PROPAGATION_REQUIRED</prop>
                 
<prop key="add*">PROPAGATION_REQUIRED</prop>
                 
<prop key="update*">PROPAGATION_REQUIRED</prop>
                 
<prop key="remove*">PROPAGATION_REQUIRED</prop>
             
</props>
         
</property>
     
</bean>

     
<bean id="userService" parent="baseTransaction">
         
<property name="target">
             
<bean class="com.phopesoft.security.service.impl.UserServiceImpl"/>
         
</property>
    
</bean> 

瀵逛簬涓婁緥錛屽垯浠ave,add,update,remove寮澶寸殑鏂規(guī)硶鎷ユ湁鍙啓鐨勪簨鍔★紝濡傛灉褰撳墠鏈夋煇涓柟娉曪紝濡傚懡鍚嶄負(fù)importExcel()錛屽垯鍥犳病鏈塼ransaction鑰屾病鏈夊啓鏉冮檺錛岃繖鏃惰嫢鏂規(guī)硶鍐呮湁insert,update,delete鎿嶄綔鐨勮瘽錛屽垯闇瑕佹墜鍔ㄨ緗甪lush model涓篎lush.AUTO,濡?/p>

session.setFlushMode(FlushMode.AUTO); 
session.save(user);  
session.flush(); 

     灝界Open Session In View鐪嬭搗鏉ヨ繕涓嶉敊錛屽叾瀹炲壇浣滅敤涓嶅皯銆傜湅鍥炰笂闈penSessionInViewFilter鐨刣oFilterInternal鏂規(guī)硶浠g爜錛岃繖涓柟娉曞疄闄呬笂鏄鐖剁被鐨刣oFilter璋冪敤鐨勶紝鍥犳錛屾垜浠彲浠ュぇ綰︿簡(jiǎn)瑙g殑OpenSessionInViewFilter璋冪敤嫻佺▼: request(璇鋒眰)->open session騫跺紑濮媡ransaction->controller->View(Jsp)->緇撴潫transaction騫禼lose session.

     涓鍒囩湅璧鋒潵寰堟紜紝灝ゅ叾鏄湪鏈湴寮鍙戞祴璇曠殑鏃跺欐病鍑虹幇闂錛屼絾璇曟兂涓嬪鏋滄祦紼嬩腑鐨勬煇涓姝ヨ闃誨鐨勮瘽錛岄偅鍦ㄨ繖鏈熼棿connection灝變竴鐩磋鍗犵敤鑰屼笉閲婃斁銆傛渶鏈夊彲鑳借闃誨鐨勫氨鏄湪鍐橨sp榪欐錛屼竴鏂歸潰鍙兘鏄〉闈㈠唴瀹瑰ぇ錛宺esponse.write鐨勬椂闂撮暱錛屽彟涓鏂歸潰鍙兘鏄綉閫熸參錛屾湇鍔″櫒涓庣敤鎴烽棿浼犺緭鏃墮棿涔呫傚綋澶ч噺榪欐牱鐨勬儏鍐靛嚭鐜版椂錛屽氨鏈夎繛鎺ユ睜榪炴帴涓嶈凍錛岄犳垚欏甸潰鍋囨鐜拌薄銆?/p>

Open Session In View鏄釜鍙屽垉鍓戯紝鏀懼湪鍏綉涓婂唴瀹瑰嫻侀噺澶х殑緗戠珯璇鋒厧鐢ㄣ?/p>

 

hibernate open session in view 鎶涘嚭寮傚父瑙e喅鏂規(guī)硶

 鍦ㄤ嬌鐢╫pen-session-in-view鐨勬椂鍊欙紝濡傛灉浣跨敤涓嶅綋錛屾湁鍙兘鎶涘嚭涓ょ寮傚父
1錛孨onUniqueObjectException
2錛屽湪閰嶅悎spring浣跨敤鐨勬椂鍊欎細(xì)鍙兘浼?xì)鎶涘嚭org.springframework.dao.InvalidDataAccessApiUsageException

鍏堣1錛岃繖涓紓甯哥殑鎶涘嚭鍘熷洜鍜岃В鍐沖姙娉曡榪欓噷錛?br /> javaeye涓婃湁浜?jiǎn)寰堝ソ鐨勪簨渚?http://www.javaeye.com/topic/11581
瑙e喅鍔炴硶鍙互鐢╩erge錛屼篃鍙互鍒殑鍔炴硶銆?br /> 鍑虹幇鐨勫師鍥狅紝鍙互鍙傝冧竴涓嬫垜鍓嶈竟鐨勬枃绔犱腑灝唌erge鍜寀pdate鐨勫尯鍒殑鍐呭銆?br /> http://m.tkk7.com/dreamstone/archive/2007/07/29/133071.html

2鐨勮В鍐沖姙娉曪細(xì)鍦ㄨ繖閲?br /> springside鐨勪竴綃囨枃绔犲仛浜?jiǎn)璇l嗚鏄?br /> http://calvin.blog.javascud.org/post/46.htm

濂戒簡(jiǎn)錛岀幇鍦ㄩ棶棰樿В鍐充簡(jiǎn)錛屼絾鍏充簬open-session-in-view鐨勪嬌鐢ㄨ繕鏈変竴浜涙帰璁紝鏄惁搴旇浣跨敤錛屼嬌鐢ㄧ殑濂藉涓庡潖澶勩?br /> 瑙佽繖涓ょ瘒jdon涓婄殑鏂囩珷:
http://www.jdon.com/jivejdon/thread/22374.html
http://www.jdon.com/jivejdon/thread/28955.html



semovy 2007-09-09 18:15 鍙戣〃璇勮
]]>
Spring 涓?Hibernate 鐨勫歡榪熷姞杞藉拰 Dao 妯″紡http://m.tkk7.com/WshmAndLily/articles/143690.htmlsemovysemovySat, 08 Sep 2007 14:49:00 GMThttp://m.tkk7.com/WshmAndLily/articles/143690.htmlhttp://m.tkk7.com/WshmAndLily/comments/143690.htmlhttp://m.tkk7.com/WshmAndLily/articles/143690.html#Feedback0http://m.tkk7.com/WshmAndLily/comments/commentRss/143690.htmlhttp://m.tkk7.com/WshmAndLily/services/trackbacks/143690.html闃呰鍏ㄦ枃

semovy 2007-09-08 22:49 鍙戣〃璇勮
]]>
鍏充簬spring涓殑aop鐨勮В閲?/title><link>http://m.tkk7.com/WshmAndLily/articles/143446.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Fri, 07 Sep 2007 07:58:00 GMT</pubDate><guid>http://m.tkk7.com/WshmAndLily/articles/143446.html</guid><wfw:comment>http://m.tkk7.com/WshmAndLily/comments/143446.html</wfw:comment><comments>http://m.tkk7.com/WshmAndLily/articles/143446.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://m.tkk7.com/WshmAndLily/comments/commentRss/143446.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/WshmAndLily/services/trackbacks/143446.html</trackback:ping><description><![CDATA[<p><font face="Arial">AOP鏄疧OP鐨勫歡緇紝鏄疉spect   Oriented   Programming鐨勭緝鍐欙紝鎰忔濇槸闈㈠悜鏂歸潰緙栫▼銆侫OP瀹為檯鏄疓oF璁捐妯″紡鐨勫歡緇紝璁捐妯″紡瀛滃瓬涓嶅﹁拷姹傜殑鏄皟鐢ㄨ呭拰琚皟鐢ㄨ呬箣闂寸殑瑙h︼紝AOP鍙互璇翠篃鏄繖縐嶇洰鏍囩殑涓縐嶅疄鐜般?/font></p> <p><font face="Arial">    銆涓句緥錛氬亣璁炬湁鍦ㄤ竴涓簲鐢ㄧ郴緇熶腑錛屾湁涓涓叡浜殑鏁版嵁蹇呴』琚茍鍙戝悓鏃惰闂紝棣栧厛錛屽皢榪欎釜鏁版嵁灝佽鍦ㄦ暟鎹璞′腑錛岀О涓篋ata   Class錛屽悓鏃訛紝灝嗘湁澶氫釜璁塊棶綾伙紝涓撻棬鐢ㄤ簬鍦ㄥ悓涓鏃跺埢璁塊棶榪欏悓涓涓暟鎹璞°?br /> 銆銆涓轟簡(jiǎn)瀹屾垚涓婅堪騫跺彂璁塊棶鍚屼竴璧勬簮鐨勫姛鑳斤紝闇瑕佸紩鍏ラ攣Lock鐨勬蹇碉紝涔熷氨鏄錛屾煇涓椂鍒伙紝褰撴湁涓涓闂被璁塊棶榪欎釜鏁版嵁瀵硅薄鏃訛紝榪欎釜鏁版嵁瀵硅薄蹇呴』涓婇攣Locked錛岀敤瀹屽悗灝辯珛鍗寵В閿乽nLocked錛屽啀渚涘叾瀹冭闂被璁塊棶銆?br /> 銆銆浣跨敤浼犵粺鐨勭紪紼嬩範(fàn)鎯紝鎴戜滑浼?xì)鍒涘晦Z竴涓娊璞$被錛屾墍鏈夌殑璁塊棶綾葷戶鎵胯繖涓娊璞$埗綾伙紝濡備笅錛?br /> abstract   class   Worker{<br /> 銆銆abstract   void   locked();<br /> 銆銆abstract   void   accessDataObject();<br /> 銆銆abstract   void   unlocked();<br /> }<br /> <br /> 銆緙虹偣錛?/font></p> <p><font face="Arial">        *   accessDataObject()鏂規(guī)硶闇瑕佹湁“閿?#8221;鐘舵佷箣綾葷殑鐩稿叧浠g爜銆?br />         *   Java鍙彁渚涗簡(jiǎn)鍗曠戶鎵匡紝鍥犳鍏蜂綋璁塊棶綾誨彧鑳界戶鎵胯繖涓埗綾伙紝濡傛灉鍏蜂綋璁塊棶綾昏繕瑕佺戶鎵垮叾瀹冪埗綾伙紝姣斿鍙﹀涓涓Worker鐨勭埗綾伙紝灝嗘棤娉曟柟渚垮疄鐜般?br />         *   閲嶇敤琚墦鎶樻墸錛屽叿浣撹闂被鍥犱負(fù)涔熷寘鍚?#8220;閿?#8221;鐘舵佷箣綾葷殑鐩稿叧浠g爜錛屽彧鑳借閲嶇敤鍦ㄧ浉鍏蟲湁“閿?#8221;鐨勫満鍚堬紝閲嶇敤鑼冨洿寰堢獎(jiǎng)銆?/font></p> <p><font face="Arial">            浠旂粏鐮旂┒榪欎釜搴旂敤鐨?#8220;閿?#8221;錛屽畠鍏跺疄鏈変笅鍒楃壒鎬э細(xì)<br />         *   “閿?#8221;鍔熻兘涓嶆槸鍏蜂綋璁塊棶綾葷殑棣栬鎴栦富瑕佸姛鑳斤紝璁塊棶綾諱富瑕佸姛鑳芥槸璁塊棶鏁版嵁瀵硅薄錛屼緥濡傝鍙栨暟鎹垨鏇存敼鍔ㄤ綔銆?nbsp; </font></p> <p><font face="Arial">“閿?#8221;琛屼負(fù)鍏跺疄鏄拰鍏蜂綋璁塊棶綾葷殑涓昏鍔熻兘鍙互鐙珛銆佸尯鍒嗗紑鏉ョ殑</font></p> <p><font face="Arial">“閿?#8221;鍔熻兘鍏跺疄鏄繖涓郴緇熺殑涓涓旱鍚戝垏闈紝娑夊強(qiáng)璁稿綾匯佽澶氱被鐨勬柟娉曘?nbsp; </font></p> <p><font face="Arial">銆鍥犳錛屼竴涓柊鐨勭▼搴忕粨鏋勫簲璇ユ槸鍏蟲敞緋葷粺鐨勭旱鍚戝垏闈紝渚嬪榪欎釜搴旂敤鐨?#8220;閿?#8221;鍔熻兘錛岃繖涓柊鐨勭▼搴忕粨鏋勫氨鏄痑spect錛堟柟闈級(jí)<br /> 銆銆鍦ㄨ繖涓簲鐢ㄤ腑錛?#8220;閿?#8221;鏂歸潰錛坅spect錛夊簲璇ユ湁浠ヤ笅鑱岃矗錛?br /> 銆銆鎻愪緵涓浜涘繀澶囩殑鍔熻兘錛屽琚闂璞″疄鐜板姞閿佹垨瑙i攣鍔熻兘銆備互淇濊瘉鎵鏈夊湪淇敼鏁版嵁瀵硅薄鐨勬搷浣滀箣鍓嶈兘澶熻皟鐢╨ock()鍔犻攣錛屽湪瀹冧嬌鐢ㄥ畬鎴愬悗錛岃皟鐢╱nlock()瑙i攣銆?br /> AOP搴旂敤鑼冨洿</font></p> <p><font face="Arial">銆銆寰堟槑鏄撅紝AOP闈炲父閫傚悎寮鍙慗2EE瀹瑰櫒鏈嶅姟鍣紝鐩墠JBoss   4.0姝f槸浣跨敤AOP妗嗘灦榪涜寮鍙戙?br /> 銆銆鍏蜂綋鍔熻兘濡備笅錛?br /> Authentication   鏉冮檺<br /> Caching   緙撳瓨<br /> Context   passing   鍐呭浼犻?br /> Error   handling   閿欒澶勭悊<br /> Lazy   loading銆鎳掑姞杞?br /> Debugging銆銆璋冭瘯<br /> logging,   tracing,   profiling   and   monitoring銆璁板綍璺熻釜銆浼樺寲銆鏍″噯</font></p> <p><font face="Arial"><br /> Performance   optimization銆鎬ц兘浼樺寲<br /> Persistence銆銆鎸佷箙鍖?br /> Resource   pooling銆璧勬簮姹?br /> Synchronization銆鍚屾<br /> Transactions   浜嬪姟<br /> AOP鏈夊繀瑕佸悧錛?br /> 銆銆褰撶劧錛屼笂榪板簲鐢ㄨ寖渚嬪湪娌℃湁浣跨敤AOP鎯呭喌涓嬶紝涔熷緱鍒頒簡(jiǎn)瑙e喅錛屼緥濡侸Boss   3.XXX涔熸彁渚涗簡(jiǎn)涓婅堪搴旂敤鍔熻兘錛屼絾鏄病鏈変嬌鐢ˋOP銆?br /> 銆銆浣嗘槸錛屼嬌鐢ˋOP鍙互璁╂垜浠粠涓涓洿楂樼殑鎶借薄姒傚康鏉ョ悊瑙h蔣浠剁郴緇燂紝AOP涔熻鎻愪緵涓縐嶆湁浠峰肩殑宸ュ叿銆傚彲浠ヨ繖涔堣錛氬洜涓轟嬌鐢ˋOP緇撴瀯錛岀幇鍦↗Boss   4.0鐨勬簮鐮佽姣擩Boss   3.X瀹規(guī)槗鐞嗚В澶氫簡(jiǎn)錛岃繖瀵逛簬涓涓ぇ鍨嬪鏉傜郴緇熸潵璇存槸闈炲父閲嶈鐨勩?br /> 銆銆浠庡彟澶栦竴涓柟闈㈣錛屽ソ鍍忎笉鏄墍鏈夌殑浜洪兘闇瑕佸叧蹇?jī)AOP錛屽畠鍙兘鏄竴縐嶆灦鏋勮璁$殑閫夋嫨錛屽鏋滈夋嫨J2EE緋葷粺錛孉OP鍏蟲敞鐨勪笂榪伴氱敤鏂歸潰閮藉凡緇忚J2EE瀹瑰櫒瀹炵幇浜?jiǎn)锛孞2EE搴旂敤緋葷粺寮鍙戣呭彲鑳介渶瑕佹洿澶氬湴鍏蟲敞琛屼笟搴旂敤鏂歸潰aspect銆?/font></p> <img src ="http://m.tkk7.com/WshmAndLily/aggbug/143446.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/WshmAndLily/" target="_blank">semovy</a> 2007-09-07 15:58 <a href="http://m.tkk7.com/WshmAndLily/articles/143446.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>spring涓厤緗簩綰х紦瀛?http://m.tkk7.com/WshmAndLily/articles/137244.htmlsemovysemovyThu, 16 Aug 2007 06:12:00 GMThttp://m.tkk7.com/WshmAndLily/articles/137244.htmlhttp://m.tkk7.com/WshmAndLily/comments/137244.htmlhttp://m.tkk7.com/WshmAndLily/articles/137244.html#Feedback0http://m.tkk7.com/WshmAndLily/comments/commentRss/137244.htmlhttp://m.tkk7.com/WshmAndLily/services/trackbacks/137244.html1.棣栧厛,鍦╯pring鐨刪ibernate閰嶇疆閲?鎴戠殑鏄痑pplicationContext-hibernate.xml) 鍔犱笂濡備笅灞炴?

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">         
  <property name="dataSource">
   <ref bean="dataSource"/>
  </property>
  <property name="mappingResources">
   <list>
    <value>org/appfteaching/model/TArticleclass.hbm.xml</value>
   </list>
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
          <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
          <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
          <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
          <prop key="hibernate.cache.use_query_cache">true</prop>
          <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
   </props>   
  </property>  
 </bean> 

2.鍏舵,鍦╯rc鐩綍涓嬬殑ehcache.xml涓厤緗涓嬩俊鎭?濡傛灉鏄粯璁hcache.xml鍒欎細(xì)鏈?lt;cache name="sampleCache1">鍜?lt;cache name="sampleCache2>",鍘繪帀)

<cache name="org.hibernate.cache.StandardQueryCache"
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="300"
        timeToLiveSeconds="4200"
        overflowToDisk="true"
        />

    <!-- Sample cache named sampleCache2
        This cache contains 1000 elements. Elements will always be held in memory.
        They are not expired. -->

    <cache name="org.hibernate.cache.UpdateTimestampsCache"
        maxElementsInMemory="5000"
        eternal="true"
        timeToIdleSeconds="0"
        timeToLiveSeconds="0"
        overflowToDisk="false"
        />

3.灝嗕綘瑕佺紦瀛樼殑model鍔犺繘ehcache.xml閲?/p>

<cache name="org.appfteaching.model.TArticleclass"
     maxElementsInMemory="1000"
        eternal="false"
        timeToIdleSeconds="100"
        timeToLiveSeconds="4200"
        overflowToDisk="true"
     />  

4.鏈鍚庝竴姝?鍦═Articleclass.hbm.xml閲屽姞涓?/p>

<cache usage="read-write"/>

鍚姩Tomcat,濡傚彂鐜板涓嬮敊璇?/p>

Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.
Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.

鍒欐槸絎簩姝ユ病鏈夊仛,鍔犱笂鍗沖彲.閰嶇疆瀹屾瘯



semovy 2007-08-16 14:12 鍙戣〃璇勮
]]>
ApplicationContexthttp://m.tkk7.com/WshmAndLily/articles/136979.htmlsemovysemovyWed, 15 Aug 2007 09:15:00 GMThttp://m.tkk7.com/WshmAndLily/articles/136979.htmlhttp://m.tkk7.com/WshmAndLily/comments/136979.htmlhttp://m.tkk7.com/WshmAndLily/articles/136979.html#Feedback0http://m.tkk7.com/WshmAndLily/comments/commentRss/136979.htmlhttp://m.tkk7.com/WshmAndLily/services/trackbacks/136979.html   1. FileSystemXmlApplicationContext
           eg1. ApplicationContext ctx = new FileSystemXmlApplicationContext("bean.xml"); //鍔犺澆鍗曚釜閰嶇疆鏂囦歡
           eg2.
                   String[] locations = {"bean1.xml", "bean2.xml", "bean3.xml"};
                   ApplicationContext ctx = new FileSystemXmlApplicationContext(locations ); //鍔犺澆澶?font color=#333333>涓厤緗枃浠?br>           eg3.        
        ApplicationContext ctx =new FileSystemXmlApplicationContext("D:/project/bean.xml");//鏍規(guī)嵁鍏蜂綋璺緞鍔犺澆鏂囦歡
  2. ClassPathXmlApplicationContext
           eg1.  ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");
           eg2.
                   String[] locations = {"bean1.xml", "bean2.xml", "bean3.xml"};
                   ApplicationContext ctx = new ClassPathXmlApplication(locations);
           娉細(xì)鍏朵腑FileSystemXmlApplicationContext鍜孋lassPathXmlApplicationContext涓嶣eanFactory鐨剎ml鏂囦歡瀹氫綅鏂瑰紡涓鏍鋒槸鍩轟簬璺緞鐨勩?br>3. XmlWebApplicationContext
       eg1. ServletContext servletContext = request.getSession().getServletContext();    
            ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);



娉?: 涓鑸槸 ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());


 鍔犺澆鍣ㄧ洰鍓嶆湁涓ょ閫夋嫨錛欳ontextLoaderListener鍜孋ontextLoaderServlet銆?
         榪欎袱鑰呭湪鍔熻兘涓婂畬鍏ㄧ瓑鍚岋紝鍙槸涓涓槸鍩轟簬Servlet2.3鐗堟湰涓柊寮曞叆鐨凩istener鎺ュ彛瀹炵幇錛岃屽彟涓涓熀浜嶴ervlet鎺ュ彛瀹炵幇銆傚紑鍙戜腑鍙牴鎹洰鏍嘩eb瀹瑰櫒鐨勫疄闄呮儏鍐佃繘琛岄夋嫨銆?

閰嶇疆闈炲父綆鍗曪紝鍦╳eb.xml涓鍔狅細(xì)
<listener>
       <listener-class>
          org.springframework.web.context.ContextLoaderListener
       </listener-class>
</listener>
鎴栵細(xì)
<servlet>
         <servlet-name>context</servlet-name>
         <servlet-class>
           org.springframework.web.context.ContextLoaderServlet
         </servlet-class>
         <load-on-startup>1</load-on-startup>
</servlet>


閫氳繃浠ヤ笂閰嶇疆錛學(xué)eb瀹瑰櫒浼?xì)鑷姩鍔犺?WEB-INF/applicationContext.xml鍒濆鍖?
ApplicationContext瀹炰緥錛屽鏋滈渶瑕佹寚瀹氶厤緗枃浠朵綅緗紝鍙氳繃context-param鍔犱互鎸囧畾錛?
<context-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>/WEB-INF/myApplicationContext.xml</param-value>
</context-param>

閰嶇疆瀹屾垚涔嬪悗錛屽嵆鍙氳繃
WebApplicationContextUtils.getWebApplicationContext鏂規(guī)硶鍦╓eb搴旂敤涓幏鍙朅pplicationContext寮曠敤銆?

濡傦細(xì)ApplicationContext ctx=WebApplicationContextUtils.getWebApplicationContext();
         LoginAction action=(LoginAction)ctx.getBean("action");



semovy 2007-08-15 17:15 鍙戣〃璇勮
]]>
spring mail鍙戦?/title><link>http://m.tkk7.com/WshmAndLily/articles/116822.html</link><dc:creator>semovy</dc:creator><author>semovy</author><pubDate>Fri, 11 May 2007 09:58:00 GMT</pubDate><guid>http://m.tkk7.com/WshmAndLily/articles/116822.html</guid><wfw:comment>http://m.tkk7.com/WshmAndLily/comments/116822.html</wfw:comment><comments>http://m.tkk7.com/WshmAndLily/articles/116822.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/WshmAndLily/comments/commentRss/116822.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/WshmAndLily/services/trackbacks/116822.html</trackback:ping><description><![CDATA[<p>package com.action;</p> <p>import java.util.ArrayList;<br>import java.util.Date;<br>import java.util.Iterator;<br>import java.util.List;</p> <p>import javax.activation.DataHandler;<br>import javax.activation.FileDataSource;<br>import javax.mail.Message;<br>import javax.mail.MessagingException;<br>import javax.mail.Multipart;<br>import javax.mail.internet.InternetAddress;<br>import javax.mail.internet.MimeBodyPart;<br>import javax.mail.internet.MimeMessage;<br>import javax.mail.internet.MimeMultipart;</p> <p>import org.springframework.context.ApplicationContext;<br>import org.springframework.context.support.FileSystemXmlApplicationContext;<br>import org.springframework.mail.SimpleMailMessage;<br>import org.springframework.mail.javamail.JavaMailSender;<br>import org.springframework.mail.javamail.MimeMessagePreparator;</p> <p> </p> <p>public class SpringMail {<br> public static void main(String[] args) throws Exception {<br>        ApplicationContext ctx = new FileSystemXmlApplicationContext(<br>                "applicationContext.xml");<br>        JavaMailSender sender = (JavaMailSender) ctx.getBean("mailSender");<br>        SpringMail springMail = new SpringMail();<br>        <br>        //嫻嬭瘯鍙戦佸彧鏈夋枃鏈俊鎭殑綆鍗曟祴璇?br>        springMail.sendTextMail(sender);<br>        <br>        //嫻嬭瘯鍙戦佸甫闄勪歡鐨勯偖浠?br>        springMail.sendMimeMessage(sender);<br>    }<br>    <br>    /** *//**<br>     * 嫻嬭瘯鍙戦佸彧鏈夋枃鏈俊鎭殑綆鍗曟祴璇?br>     * @param sender 閭歡鍙戦佸櫒<br>     * @throws Exception<br>     */<br>    private void sendTextMail(JavaMailSender sender) throws Exception {<br>        SimpleMailMessage mail = new SimpleMailMessage();<br>        mail.setTo("<a href="mailto:superman_wshm@126.com">superman_wshm@126.com</a>");<br>        mail.setFrom("<a href="mailto:superman_wshm@126.com">superman_wshm@126.com</a>");<br>        mail.setSubject("test by amigo");<br>        mail.setText("spring Mail鐨勭畝鍗曟祴璇?);<br>        sender.send(mail);<br>        <br>        System.out.println("鎴愬姛鍙戦佹枃鏈枃浠訛紒");<br>    }<br>    <br>    /** *//**<br>     * 鍙戦佸甫闄勪歡鐨勯偖浠?br>     * @param sender 閭歡鍙戦佸櫒 <br>     * @throws Exception<br>     */<br>    private void sendMimeMessage(final JavaMailSender sender) throws Exception {<br>        //闄勪歡鏂囦歡闆嗗悎<br>        final List files = new ArrayList();<br>        MimeMessagePreparator mimeMail = new MimeMessagePreparator() {<br>            public void prepare(MimeMessage mimeMessage) throws MessagingException {<br>                mimeMessage.setRecipient(Message.RecipientType.TO, <br>                        new InternetAddress("<a href="mailto:superman_wshm@126.com">superman_wshm@126.com</a>"));<br>                mimeMessage.setFrom(new InternetAddress("<a href="mailto:superman_wshm@126.com">superman_wshm@126.com</a>"));<br>                mimeMessage.setSubject("Spring鍙戦佸甫闄勪歡鐨勯偖浠?, "gb2312"); <br>                <br>                Multipart mp = new MimeMultipart();<br>                <br>                //鍚慚ultipart娣誨姞姝f枃</p> <p>                MimeBodyPart content = new MimeBodyPart();<br>                content.setText("鍐呭惈spring閭歡鍙戦佺殑渚嬪瓙錛岃鏌ユ敹!");<br>                <br>                //鍚慚imeMessage娣誨姞錛圡ultipart浠h〃姝f枃錛?br>                mp.addBodyPart(content);<br>                files.add("com/action/SpringMail.java");<br>                files.add("applicationContext.xml");<br>                <br>                //鍚慚ultipart娣誨姞闄勪歡<br>                Iterator it = files.iterator();<br>                while(it.hasNext()) {<br>                    MimeBodyPart attachFile = new MimeBodyPart();<br>                    String filename = it.next().toString();<br>                    FileDataSource fds = new FileDataSource(filename);<br>                    attachFile.setDataHandler(new DataHandler(fds));<br>                    attachFile.setFileName(fds.getName());<br>                    mp.addBodyPart(attachFile);<br>                }<br>                <br>                files.clear();<br>                <br>                //鍚慚ultipart娣誨姞MimeMessage<br>                mimeMessage.setContent(mp);<br>                mimeMessage.setSentDate(new Date());<br>            }<br>        };</p> <p>        //鍙戦佸甫闄勪歡鐨勯偖浠?br>        sender.send(mimeMail);<br>        <br>        System.out.println("鎴愬姛鍙戦佸甫闄勪歡閭歡!");<br>    }</p> <p>}</p> <p><br>Spring閰嶇疆鏂囦歡applicationContext.xml<br><br><?xml version="1.0" encoding="UTF-8"?><br><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "<a ></p> <p><beans><br> <bean id="mailSender"<br>  class="org.springframework.mail.javamail.JavaMailSenderImpl"><br>  <property name="host"><br>   <value>smtp.126.com</value><br>  </property><br>  <property name="javaMailProperties"><br>   <props><br>    <prop key="mail.smtp.auth">true</prop><br>    <prop key="mail.smtp.timeout">25000</prop><br>   </props><br>  </property><br>  <property name="username"><br>   <value>superman_wshm</value><br>  </property><br>  <property name="password"><br>   <value>******</value><br>  </property><br> </bean></p> <p><br></beans><br><br><br> 鍒氭墠鍙戠幇涓bug錛屽綋闄勪歡鍚嶄負(fù)涓枃鏃訛紝浼?xì)鍑虹庮C腑鏂囦貢鐮侀棶棰橈紝瀵箂endMimeMessage鏂規(guī)硶榪涜浜?jiǎn)閮ㄥ垎淇敼锛屽涓嬪Q?br>    </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">sun.misc.BASE64Encoder enc </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> sun.misc.BASE64Encoder();<br><img src="http://m.tkk7.com/Images/OutliningIndicators/None.gif" align=top>                files.add(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">src/SpringMail.java</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://m.tkk7.com/Images/OutliningIndicators/None.gif" align=top>                files.add(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">src/applicationContext.xml</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://m.tkk7.com/Images/OutliningIndicators/None.gif" align=top>                files.add(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">src/璋㈡槦鏄?xml</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>                </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">鍚慚ultipart娣誨姞闄勪歡</span><span style="COLOR: #008000"><br><img src="http://m.tkk7.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">                Iterator it </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> files.iterator();<br><img id=Codehighlighter1_342_772_Open_Image onclick="this.style.display='none'; Codehighlighter1_342_772_Open_Text.style.display='none'; Codehighlighter1_342_772_Closed_Image.style.display='inline'; Codehighlighter1_342_772_Closed_Text.style.display='inline';" src="http://m.tkk7.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_342_772_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_342_772_Closed_Text.style.display='none'; Codehighlighter1_342_772_Open_Image.style.display='inline'; Codehighlighter1_342_772_Open_Text.style.display='inline';" src="http://m.tkk7.com/Images/OutliningIndicators/ContractedBlock.gif" align=top>             </span><span style="COLOR: #0000ff">while </span><span style="COLOR: #000000">(it.hasNext()) </span><span id=Codehighlighter1_342_772_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_342_772_Open_Text><span style="COLOR: #000000">{<br><img src="http://m.tkk7.com/Images/OutliningIndicators/InBlock.gif" align=top>                    MimeBodyPart attachFile </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> MimeBodyPart();<br><img src="http://m.tkk7.com/Images/OutliningIndicators/InBlock.gif" align=top>                    String filename </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> it.next().toString();<br><img src="http://m.tkk7.com/Images/OutliningIndicators/InBlock.gif" align=top>                    FileDataSource fds </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> FileDataSource(filename);<br><img src="http://m.tkk7.com/Images/OutliningIndicators/InBlock.gif" align=top>                    attachFile.setDataHandler(</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> DataHandler(fds));<br><img src="http://m.tkk7.com/Images/OutliningIndicators/InBlock.gif" align=top>                    attachFile.setFileName(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">=?GBK?B?</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">enc.encode(fds.getName().getBytes())</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/InBlock.gif" align=top>                    mp.addBodyPart(attachFile);<br><img src="http://m.tkk7.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>                }</span></span></div> <img src ="http://m.tkk7.com/WshmAndLily/aggbug/116822.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/WshmAndLily/" target="_blank">semovy</a> 2007-05-11 17:58 <a href="http://m.tkk7.com/WshmAndLily/articles/116822.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Spring MVChttp://m.tkk7.com/WshmAndLily/articles/104190.htmlsemovysemovyFri, 16 Mar 2007 03:50:00 GMThttp://m.tkk7.com/WshmAndLily/articles/104190.htmlhttp://m.tkk7.com/WshmAndLily/comments/104190.htmlhttp://m.tkk7.com/WshmAndLily/articles/104190.html#Feedback0http://m.tkk7.com/WshmAndLily/comments/commentRss/104190.htmlhttp://m.tkk7.com/WshmAndLily/services/trackbacks/104190.html1.鎬諱綋璁捐

聽聽聽聽聽聽MVC妗嗘灦濡係truts銆乄ebwork錛岄兘鍦⊿ervlet鐨勫熀紜涓婂垱寤轟簡(jiǎn)涓涓嚜宸辯殑緇濆絀洪棿錛屽湪鑷繁鐨勭┖闂撮噷瀹氫箟MVC涓栫晫鍜岃鍒欍傛棤璁鴻繖涓笘鐣屽畾涔夊緱鏄惁婕備寒錛岀▼搴忓憳閮芥湁涓涓涔?fàn)涓栫晫鐨剺q囩▼銆?/p>

聽聽聽聽聽 鑰孲pring MVC鍒欏畬鍏ㄤ繚鐣欑潃Servlet姒傚康涓殑request錛宺esponse鍜宻ession錛屽茍娌℃湁寮哄埗寤虹珛涓涓嚜宸辯殑姒傚康妯″瀷錛堝綋鐒?dòng)灱屼粬涔熸湁寰堢儌鐨凷impleFormController錛屼絾浣犲畬鍏ㄥ彲浠ユ妸瀹冭涪鍦ㄤ竴鏃佷笉綆★級(jí)錛屼篃涓嶅己鍒墮渶瑕丗ormBean鍜屼竴鍫哫ML瀹氫箟銆?/p>

聽聽聽聽聽 鍚屾椂錛屽畠閫忔槑瀹屾垚浜?jiǎn)涓嶴pring鐨勯泦鎴愶紝Multi-action鐨勬淳鍙戯紝鎻愪緵浜?jiǎn)缁戝畾request鏁版嵁鐢ㄧ殑binder絳夊熀鏈珹PI銆?/p>

聽聽聽聽聽聽鎵浠ワ紝濡傛灉鎯崇畝鍗曪紝浣跨敤Spring MVC鐨勫師濮嬪艦鎬佹槸涓涓緢濂界殑錛岀被浼間簬RoR涓瑼ctionPack鐨勬柟妗堛?/p>

聽聽聽聽聽 鎺ㄨ崘浣跨敤涓涓狢ontroller鍝嶅簲涓緇勭浉鍏沖姩浣滅殑MultiActionController銆傚悓鏃訛紝铏界劧涓鐐逛笉鍠滄FormController瀹氫箟鐨勬蹇墊ā鍨嬶紝浣嗚繕鏄笉褰卞搷鍙戞尌鎷挎潵涓諱箟錛屽湪鍏辨ф瘮杈冩槑鏄懼悗鍙扮鐞嗘ā鍧楋紝瀹氫箟MultiActionFormController錛岃嚜鍔ㄥ畬鎴愭煇浜涘叡鍚岀殑Form嫻佺▼銆?/p>

聽聽聽聽聽 浣犺繕鏄緢鍠滄WebWork?濂藉湪鎴戜滑涔熸彁渚涗簡(jiǎn)sample錛岃2.4 WebWork 銆?/p>

2.鍐欑粰鍦ㄧ敤鍏朵粬MVC妗嗘灦紼嬪簭鍛樼殑蹇熷叆闂?/h2>

聽聽聽聽聽 涔熻錛屾墍鏈夌▼搴忓憳閮藉厛鏀句笅鑷繁妗嗘灦閲岀殑姒傚康妯″瀷錛岃繕鍘熷洖涓涓狫SP/Servlet紼嬪簭鍛樼殑瑙掑害錛屾濊冧竴涓狫SP/Servlet妗嗘灦闇瑕佺殑鍔熻兘銆?/p>

聽聽聽聽聽0.聽閰嶇疆鏂囦歡

聽聽聽聽聽聽聽聽 Spring鐨勯厤緗枃浠墮粯璁や負(fù)WEB-INF/xxxx-servelet.xml銆?/p>

聽聽聽聽聽聽聽聽 鍏朵腑xxx涓簑eb.xml涓璷rg.springframework.web.servlet.DispatcherServlet鐨剆ervlet-name銆?/p>

聽聽聽聽 1. 涓嶴pring闆嗘垚鍙?qiáng)IOC

聽聽聽聽聽聽聽聽聽 澶╃劧鍏紝鐢盌ispatcherServlet瀹屾垚銆?/p>

聽聽聽聽聽 2. Action鍙?qiáng)Multi-Action 鍒嗗彂

聽聽聽聽聽聽聽聽聽 Spring灝嗘寜鐓ч厤緗枃浠跺畾涔夌殑URL錛孧apping鍒板叿浣揅ontroller綾伙紝鍐嶆牴鎹甎RL閲岀殑action= xxx鎴栧叾浠栧弬鏁幫紝鍒╃敤鍙嶅皠璋冪敤Controller閲屽搴旂殑Action鏂規(guī)硶銆?/p>

聽聽聽聽聽 3. 杈撳叆鏁版嵁緇戝畾

聽聽聽聽聽聽聽聽聽 Spring鎻愪緵Binder 閫氳繃鍚嶅瓧鐨勪竴涓瀵瑰簲鍙嶅皠緇戝畾Pojo錛屼篃鍙互鐩存帴浠巖equest.getParameter()鍙栨暟鎹?/p>

聽聽聽聽聽聽聽聽聽 濡傛灉娌℃湁鍙﹀鍔犲叆妗嗘灦灝佽錛岄渶瑕佹墜宸ヨ皟鐢˙inder.

聽聽聽聽聽 4. 杈撳叆鏁版嵁楠岃瘉

聽聽聽聽聽聽聽聽聽 Sping 鎻愪緵浜?a >Validator鎺ュ彛錛岃孲pring Module榪樻暣鍚堜簡(jiǎn)Commons-Validaor 銆?/p>

聽聽聽聽聽 5. 緇撴灉鏁版嵁鏀懼洖View

聽聽聽聽聽聽聽聽聽 鏈変釜ModelAndView鐨勬蹇碉紝浠h〃浜?jiǎn)杩斿洖鐨刅iew鍚嶅強(qiáng)鏁版嵁(Model錛屼竴涓狹ap)銆傚彲浠ョ敤modelAndView.addObject()鏀懼叆鏁版嵁銆傚綋鐒?dòng)灱屼篃鍙互鐩存帴request.setAttribute()銆?/p>

聽聽聽聽聽 6. Interceptor

聽聽聽聽聽聽聽聽聽 AOP姒傚康錛屽叾瀹濻ervlet閲岄潰鏃╂湁Filter姒傚康錛屼笉榪嘔nteceptor鍙互鏇寸伒媧葷殑Mapping錛屽彟鎻愪緵postHandle鐨勬彃鍏ョ偣

聽聽聽聽聽聽聽聽聽 preHandle() handler寮宸ヤ箣鍓嶃?br />聽聽聽聽聽聽聽聽聽聽postHandle() hander寮宸ヤ箣鍚庯紝浣咲ispatchServlet榪樻病鏈夋覆鏌撻〉闈€?br />聽聽聽聽聽聽聽聽聽聽afterCompletion() 涓鍒囧畬宸ヤ箣鍚庛?br />聽聽聽聽聽聽聽聽

聽聽聽聽聽 7. Redirect錛孎orward欏甸潰鍙?qiáng)Token闃叉閲嶅鎻愪氦銆?/strong>

聽聽聽聽聽聽聽聽聽 Spring鎻愪緵 "redirect:index.jsp", "forward:index.jsp"榪欐牱鐨勭畝鍐欍?/p>

聽聽聽聽聽聽聽聽聽 Spring Simple Form鎻愪緵浜?jiǎn)闃叉閲嶅鎻愪氦鐨勬満鍒躲?/p>

聽聽聽聽聽 8. 濡傛灉鎯崇洿鎺ョ紪鍐橰esponse榪斿洖瀛楃涓? 鑰屼笉鏄繑鍥炰竴涓猇iew

聽聽聽聽聽聽聽聽聽 灝嗗嚱鏁扮殑榪斿洖綾誨瀷璁句負(fù)void錛屼嬌鐢╯s灝佽鐨?rendText(response,String text)鍑芥暟銆?/p>

3.Spring MVC Multi-action

3.1 鍩烘湰閰嶇疆

   <bean id="methodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
聽聽聽聽聽聽聽 <property name="paramName">
聽聽聽聽聽聽聽聽聽聽聽 <value>method</value>
聽聽聽聽聽聽聽 </property>
聽聽聽聽聽聽聽 <property name="defaultMethodName">
聽聽聽聽聽聽聽聽聽聽聽 <value>index</value>聽聽聽聽聽聽 聽 </property> </bean>

浠ヤ笂閰嶇疆灝嗘寜xxx.do?method= list 灝嗚皟鐢╟ontroller鐨刲ist()鏂規(guī)硶

涓嶈繃榪樿浜夊彇鏃╂棩鏀逛負(fù)Web2.0寮忕殑鍐欐硶./book/list.htm 瑕佷紭浜?book.do?action= list銆?/p>

鍏朵綑閰嶇疆鍜屽叾浠朣pring MVC閰嶇疆宸笉澶氾紝璇風(fēng)湅bookstore-servlet.xml錛岀暀鎰忎笅闈㈠嚑涓叧閿妭鐐?br /><bean id="exceptionResolver">
<bean id="methodNameResolver">
<bean id="viewResolver">
<bean id="urlMapping">(鐣欐剰鏈鏂扮殑urlMapping綆鍐欒娉?)

4.SpringSide BaseController

聽聽聽緇ф壙浜嶴pring鐨凪ultiActionController, 瀵瑰叾浣滀簡(jiǎn)灝戦噺鎵╁睍--涓昏鏄鏁版嵁緇戝畾鐨勬墿灞曪紝榪樺姞浜?jiǎn)涓涓猄aveMessage鍑芥暟銆?/p>

聽聽聽1.瀵規(guī)暟鎹粦瀹氱殑鎵╁睍錛?/strong>

聽聽 a.InitBinder() 鍒濆鍖朆inder錛屾敞鍐屾棩鏈熺被騫跺厑璁告暟瀛楃被涓虹┖銆?/p>

聽聽聽b.瀵笲ind and Validate鍑芥暟鐨勫啀鍖呰
聽 聽鏈潵Spring宸叉湁bind鍑芥暟瀹屾垚bind and validate, 浣嗚繖涓嚱鏁頒竴鏉ユ病鏈変嬌鐢˙indException浣滆繑鍥炲艱屾槸鎶涘嚭涓涓猄ervletException鍙ソ鑷繁鍙﹀瀹炵幇涓涓猙indObject()鍑芥暟銆?/p>

聽聽聽c.鍙﹀紼嶇◢鎵╁睍浜?jiǎn)涓浜涘嚱鏁頒嬌鍏舵洿濂界敤銆?/p>

2.SaveMessage():

濡傛灉鏄痳edirect鐨勫叧緋伙紝message淇℃伅鏀懼湪request.attribute()灝變細(xì)涓㈠け錛孲aveMessage()灝嗗叾鏀懼湪session銆?br />聽閰嶅悎messageFilter錛屽湪娓叉煋欏甸潰鍓嶏紝鎶婂畠浠巗ession鍙堢Щ鍥瀝equest銆?

5.鍚庡彴綆$悊閫氱敤鐨凚aseManageController

聽聽Spring MVC涓殑SimpleFormController涓殑浜や簰鏈哄埗鏈夊煎緱鍙傝冪殑閮ㄥ垎錛屼絾鍏跺彧鏈変竴涓猳nSubmit鍑芥暟涓嶈兘寰堝ソ鐨勮〃杈綜RUD鐨勮涔夛紝鎵浠ュ皢涓よ呯粨鍚堟垚Multi-ActionFormController鏄瘮杈冨ソ鐨勬柟娉曘傞氳繃綰﹀畾鍛藉悕錛屽湪鍩虹被瀹炵幇l(fā)ist()錛宑reate()絳夊嚱鏁板拰榛樿嫻佺▼錛岃屽湪瀛愮被瀹炵幇onList(),onCreate()鍑芥暟銆?/p>

聽聽 鐩墠鍙槸鍒濇緇撳悎涓よ咃紝榪樻湁寰堝ぇ鐨勬敼榪涚┖闂淬?/p>

聽 聽鍙傝冧簡(jiǎn)RoR涓殑鍛藉悕銆侭aseManageController鍗蟲寜鐓ф鍛藉悕瀹氫箟鍩虹被銆?/p>

  1. list 鏄劇ず瀵硅薄鍒楄〃鐨勯〉闈?/font>
  2. create鏂板瀵硅薄鐨勮緭鍏ョ晫闈?/div>
  3. edit 淇敼瀵硅薄鐨勮緭鍏ョ晫闈?/div>
  4. show 鍙鏄劇ず瀵硅薄detai鐨勯〉闈?/div>
  5. save 鏂板瀵硅薄鐨勪繚瀛?/div>
  6. update 淇敼瀵硅薄鐨勪繚瀛?/div>
  7. remove 鍒犻櫎鍗曚釜瀵硅薄
  8. removeAll 鎵歸噺鍒犻櫎瀵硅薄
  9. query 鏌ヨ


semovy 2007-03-16 11:50 鍙戣〃璇勮
]]> 主站蜘蛛池模板: 女人毛片a级大学毛片免费| 国产亚洲精品福利在线无卡一 | 亚洲jjzzjjzz在线播放| 亚洲人成网站在线播放vr| 涩涩色中文综合亚洲| 99久久久国产精品免费蜜臀| 亚洲xxxx视频| 亚洲欧洲美洲无码精品VA| 在线观看成人免费视频不卡| 深夜a级毛片免费视频| 久久精品国产亚洲AV无码娇色| 日韩精品视频免费观看| 久久久久久久99精品免费观看| 亚洲无人区码一二三码区别图片| 亚洲中文字幕第一页在线| 国产精品免费观看久久| gogo免费在线观看| 亚洲国产精品日韩| xx视频在线永久免费观看| 色哟哟国产精品免费观看| 亚洲天堂福利视频| 亚洲精品午夜国产VA久久成人| 啦啦啦中文在线观看电视剧免费版| 中国国语毛片免费观看视频| 亚洲国产精品精华液| 亚洲成年人电影在线观看| 337p日本欧洲亚洲大胆裸体艺术| 女人被男人躁的女爽免费视频| 久久久久国产精品免费看| 思思久久99热免费精品6| 亚洲欧美成人综合久久久| 久久久久亚洲av无码专区| 最新国产AV无码专区亚洲 | 999国内精品永久免费观看| 亚美影视免费在线观看| 亚洲精华液一二三产区| 亚洲专区中文字幕| 久久精品国产亚洲av水果派| 国产l精品国产亚洲区在线观看| 国产jizzjizz免费看jizz| 中国在线观看免费高清完整版|