锘??xml version="1.0" encoding="utf-8" standalone="yes"?>在线免费黄色毛片,国产福利免费在线观看,青青草这里只有精品 http://www.aygfsteel.com/chenlb/category/20284.html濂借鎬т笉濡傜儌絎斿ご! zh-cn Sat, 27 Oct 2007 08:35:22 GMT Sat, 27 Oct 2007 08:35:22 GMT 60 spring 渚濊禆娉ㄥ叆鍒扮洿鎺ew 瀵硅薄 http://www.aygfsteel.com/chenlb/archive/2007/10/27/156359.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Sat, 27 Oct 2007 08:31:00 GMT http://www.aygfsteel.com/chenlb/archive/2007/10/27/156359.html http://www.aygfsteel.com/chenlb/comments/156359.html http://www.aygfsteel.com/chenlb/archive/2007/10/27/156359.html#Feedback 0 http://www.aygfsteel.com/chenlb/comments/commentRss/156359.html http://www.aygfsteel.com/chenlb/services/trackbacks/156359.html
寤轟竴涓被瀹炵幇ApplicationContextAware鎺ュ彛錛屾湁涓涓紩鐢ˋpplicationContext鐨勯潤鎬佹垚鍛橈紝鐒跺悗錛岄仐鐣欑郴緇熼渶瑕佸紩鐢╯pring綆$悊鐨刡ean鐨勫湴鏂癸紝浣跨敤榪欎釜綾匯?br />
1.姣斿錛氭垜榪欓噷寤轟竴涓猄pringContext綾?br />
package net.blogjava.chenlb;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* 姝ょ被鍙互鍙栧緱Spring鐨勪笂涓嬫枃.
* Spring 浣縩ew鏂規(guī)硶鍒涘緩鐨勫璞″彲浠ュ紩鐢╯pring綆$悊鐨刡ean.
* 2007-10-18 涓婂崍11:12:33
* @author chenlb
*/
public class SpringContext implements ApplicationContextAware {
protected static ApplicationContext context;
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
context = applicationContext;
}
public static ApplicationContext getContext() {
return context;
}
}
2.鐒跺悗鍦╯pring閰嶇疆鏂囦歡閲屽姞
< bean id ="springContext" class ="net.blogjava.chenlb.SpringContext" ></ bean >
3.鍏跺畠綾諱腑寮曠敤
MyBean myBean = (MyBean) SpringContext.getContext().getBean( " myBean " );
4.濡傛灉鑰佹槸鍐橲pringContext.getContext().getBean("...");楹葷儲錛屽彲浠ュ緩涓涓伐鍘傜被鏉ヨ繑鍥炰綘瑕佺殑bean
package net.blogjava.chenlb;
public class MyServerFactory {
public static MyBean1 getMyBean1() {
return (MyBean1) SpringContext.getContext().getBean( " myBean1 " );
}
}
^_^
]]> spring 澹版槑寮忎簨鍔?/title> http://www.aygfsteel.com/chenlb/archive/2007/08/20/138075.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Mon, 20 Aug 2007 03:39:00 GMT http://www.aygfsteel.com/chenlb/archive/2007/08/20/138075.html http://www.aygfsteel.com/chenlb/comments/138075.html http://www.aygfsteel.com/chenlb/archive/2007/08/20/138075.html#Feedback 0 http://www.aygfsteel.com/chenlb/comments/commentRss/138075.html http://www.aygfsteel.com/chenlb/services/trackbacks/138075.html
< bean id ="dataSource" class ="org.apache.commons.dbcp.BasicDataSource" destroy-method ="close" > < property name ="driverClassName" value ="com.mysql.jdbc.Driver" ></ property > < property name ="url" value ="jdbc:mysql://localhost:3306/study" ></ property > < property name ="username" value ="root" ></ property > < property name ="password" value ="" ></ property > </ bean >
浜嬪姟綆$悊鑰咃細
< bean id ="transactionManager" class ="org.springframework.jdbc.datasource.DataSourceTransactionManager" > < property name ="dataSource" ref ="dataSource" ></ property > </ bean >
琚鐞嗙殑瀵硅薄錛?br>
< bean id ="myBusinessObjectTarget" class ="mybusiness.MyBusinessObject" ></ bean >
浜嬪姟鎬т唬鐞嗗璞★細
< bean id ="myBusinessObject" class ="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" > < property name ="transactionManager" ref ="transactionManager" ></ property > < property name ="target" ref ="myBusinessObjectTarget" ></ property > < property name ="transactionAttributes" > < props > < prop key ="myBusinessMethod" > PROPAGATION_REQUIRED,-MyCheckedException </ prop > </ props > </ property > </ bean >
璇存槑錛?MyCheckedException琛ㄧず鎶涘嚭姝ゅ甯告椂鍥炴粴錛?MyCheckedException琛ㄧず鎶涘嚭姝ゅ甯告椂鎻愪氦銆?br> MyBusinessObject錛?br>
package mybusiness; /** * * 2007-8-20 涓婂崍11:26:28 * @author chenlb */ public class MyBusinessObject { public void myBusinessMethod() throws MyCheckedException { // do some resource access // return some result object or throw MycheckedException } }
澹版槑寮忎簨鍔$殑鍏朵腑涓縐嶅艦寮忋俕_^
]]> spring 瀵?conection 鐨勪簨鍔?/title> http://www.aygfsteel.com/chenlb/archive/2007/08/20/138071.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Mon, 20 Aug 2007 03:22:00 GMT http://www.aygfsteel.com/chenlb/archive/2007/08/20/138071.html http://www.aygfsteel.com/chenlb/comments/138071.html http://www.aygfsteel.com/chenlb/archive/2007/08/20/138071.html#Feedback 0 http://www.aygfsteel.com/chenlb/comments/commentRss/138071.html http://www.aygfsteel.com/chenlb/services/trackbacks/138071.html spring 瀵?JdbcTemplate……鐨勪簨鍔$鐞嗕笉鐢ㄦ媴蹇冦傚氨鏄鐩存帴Jdbc瀹炵幇鐨凞ao浜嬪姟綆$悊鏈夌偣灝忛棶棰橈紝濡傦細鎴戠洿鎺ワ紝鐢╠ataSource.getConnection()銆俿pring鏄鐞嗕笉浜嗕簨鍔$殑銆傚師鍥犳槸Jdbc瀹炵幇鐨凞ao閲岀殑connection鏄嚜鍔ㄦ彁浜ょ殑銆傝鏀圭敤緇忚繃spring 澶勭悊榪囩殑connection = DataSourceUtil.getConnection(dataSource);鎵嶈銆?br> 鎴戣繖鏈変釜渚嬪瓙鈥斺旂敤鎴鋒敞鍐岋紝鏈夊浠姐傚彧鏄緥瀛愯屼笖銆?br> 涓嬮潰鏄師濮嬬殑Dao瀹炵幇錛?br>澶囦喚鏂規(guī)硶錛?/p>
public User backUp(User user) throws SQLException { Connection conn = dataSource.getConnection(); try { PreparedStatement pstmt = conn.prepareStatement( " insert into user(name) values (?) " ); pstmt.setString( 1 , user.getName() + " 澶囦喚 " ); pstmt.executeUpdate(); pstmt = conn.prepareStatement( " select last_insert_id() " ); ResultSet rs = pstmt.executeQuery(); if (rs != null && rs.next()) { user.setUId(rs.getInt( 1 )); } } catch (SQLException e) { // TODO Auto-generated catch block throw e; } finally { if (conn != null ) { try { conn.close(); } catch (SQLException e) { System.out.println( " 鏁版嵁搴撹繛鎺ュ叧闂け璐? " ); } } } return user; }
鐜板湪瑕佹敼鎴愶細
public User backUp(User user) throws SQLException { Connection conn = DataSourceUtils.getConnection(dataSource); try { PreparedStatement pstmt = conn.prepareStatement( " insert into user(name) values (?) " ); pstmt.setString( 1 , user.getName() + " 澶囦喚 " ); pstmt.executeUpdate(); pstmt = conn.prepareStatement( " select last_insert_id() " ); ResultSet rs = pstmt.executeQuery(); if (rs != null && rs.next()) { user.setUId(rs.getInt( 1 )); } } catch (SQLException e) { throw e; } finally { DataSourceUtils.releaseConnection(conn, dataSource); } return user; }
鐒跺悗浣犲湪閫昏緫灞傚氨鍙互鐢╯pring鐨勪換浣曟柟寮忕鐞嗕簨鍔′簡銆?br>濡傦細娉ㄥ唽
public User register(User user) throws SQLException { userDao.backUp(user); userDao.insert(user); return user; }
]]> jsp 涓?寮曠敤 spring 綆$悊鐨凚ean http://www.aygfsteel.com/chenlb/archive/2007/08/13/136444.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Mon, 13 Aug 2007 09:22:00 GMT http://www.aygfsteel.com/chenlb/archive/2007/08/13/136444.html http://www.aygfsteel.com/chenlb/comments/136444.html http://www.aygfsteel.com/chenlb/archive/2007/08/13/136444.html#Feedback 0 http://www.aygfsteel.com/chenlb/comments/commentRss/136444.html http://www.aygfsteel.com/chenlb/services/trackbacks/136444.html 鐢變簬娌℃湁鐢∕VC妗嗘灦錛屾墍浠ュ湪view灞傜殑涓嶈兘鐢盨pring渚濊禆娉ㄥ叆錛岀幇鍦ㄦ垜jsp欏甸潰鍙堟兂寮曠敤Spring綆$悊鐨凚ean錛岄偅鎬庝箞鍔炪傜敤WebApplicationContextUtils甯姪綾匯俲sp欏甸潰濡備笅錛?br>
<% @ page language = " java " pageEncoding = " UTF-8 " %> <% @ page import = " org.springframework.web.context.support.WebApplicationContextUtils " %> <% @ page import = " org.springframework.web.context.WebApplicationContext " %> <% WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext( this .getServletContext()); %>
]]>spring 闃查噸澶嶆彁浜よ〃鍗?/title> http://www.aygfsteel.com/chenlb/archive/2007/05/08/115969.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Tue, 08 May 2007 07:44:00 GMT http://www.aygfsteel.com/chenlb/archive/2007/05/08/115969.html http://www.aygfsteel.com/chenlb/comments/115969.html http://www.aygfsteel.com/chenlb/archive/2007/05/08/115969.html#Feedback 0 http://www.aygfsteel.com/chenlb/comments/commentRss/115969.html http://www.aygfsteel.com/chenlb/services/trackbacks/115969.html 棣栧厛錛岄渶瑕佸皢緇ф壙浜哠impleFormController涔嬬被鐨剆essionForm璁句負true銆傝繖鏍鳳紝鍦ㄦ樉紺轟竴涓柊琛ㄥ崟鏃訛紝Spring浼氬皢command瀛樻斁鍦╯ession涓紝鑰屽湪鎻愪氦琛ㄥ崟鏃訛紝Spring浼氫粠session涓彇鍑烘command錛岄殢鍚庣珛鍗充粠session涓垹闄ゅ瓨鏀綾ommand鐨刟ttribute銆傚鏋滃彂鐜板湪session涓病鏈塩ommand錛孲pring灝嗗叾鏂畾涓洪噸澶嶆彁浜わ紝杞屾墽琛宧andleInvalidSubmit(request, response)錛屽彲瑕嗙洊姝ゆ柟娉曡礋璐i槻姝㈤噸澶嶆彁浜ょ殑浠誨姟銆傚彲浠ヨ繖涔堣錛屽綋setSessionForm(true)涔嬪悗錛屽鏋滄病鏈夊厛鍚庣粡鍘嗘樉紺鴻〃鍗曘佹彁浜よ〃鍗曠殑榪囩▼錛屽氨浼氳璁や負鏄噸澶嶆彁浜よ〃鍗曘傝屾湁涓浜涙儏鍐典笅鍗村繀欏婚噸澶嶆彁浜よ〃鍗曪紝濡傦紝淇敼鏁版嵁搴撶殑鏁版嵁鍚庯紝璇曞浘鍐欏叆鏁版嵁搴撴椂鍥犳煇浜涘紓甯稿け璐ワ紝濡傛灉姝ゆ椂寮傚父琚綋鍓嶉〉闈㈡崟鑾峰茍渚濇棫榪斿洖褰撳墠欏甸潰錛岀敱浜巆ommand宸茬粡琚玈pring鍦ㄥ悗鍙頒粠session涓Щ璧幫紝鍥犳錛屽氨琚涓烘槸鏃犳晥閲嶅鎻愪氦錛屼粠鑰屽鑷寸浜屾緇忎慨鏀瑰悗鐨勮褰曟棤娉曟紜彁浜ゅ埌鏁版嵁搴撲腑銆俬andleInvalidSubmit()蹇呴』鑰冭檻鍒拌繖縐嶆儏鍐點?
]]> spring with c3p0 http://www.aygfsteel.com/chenlb/archive/2007/03/18/104575.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Sun, 18 Mar 2007 09:06:00 GMT http://www.aygfsteel.com/chenlb/archive/2007/03/18/104575.html http://www.aygfsteel.com/chenlb/comments/104575.html http://www.aygfsteel.com/chenlb/archive/2007/03/18/104575.html#Feedback 0 http://www.aygfsteel.com/chenlb/comments/commentRss/104575.html http://www.aygfsteel.com/chenlb/services/trackbacks/104575.html http://www.aygfsteel.com/willpower88/archive/2007/01/10/92928.html 褰撴垜spring涓敤c3p0鏃剁涓嬈¤佸嚭鐜?br />org.hibernate.exception.JDBCConnectionException: could not execute query 鍒鋒柊鍚庡氨涓嶄細銆備竴鐣姌鑵懼悗鐩存帴鐢?lt;property name="" value="" />灝卞彲浠ヤ簡銆傞殢鍚庢壘鍒皐illpower88鍏勭殑blog浠栨葷粨寰楀緢濂姐?br /> 鐜錛?br />spring 2.0 c3p0-0.9.0.4 spring閰嶇疆鏂囦歡濡備笅(寮曠敤willpower88鍏勭殑錛屾敞閲婃帀鐨勯兘鏈夐棶棰樼殑錛夛細< bean聽 id ="dataSource" 聽class ="com.mchange.v2.c3p0.ComboPooledDataSource" 聽聽聽destroy-method ="close" > 聽聽聽聽聽聽聽聽聽< property聽 name ="driverClass" 聽value ="com.mysql.jdbc.Driver" 聽 /> 聽聽聽聽聽聽聽聽聽< property聽 name ="jdbcUrl" 聽value ="jdbc:mysql://localhost/test" /> 聽聽聽聽聽聽聽聽聽聽聽聽 聽聽聽聽聽聽聽聽聽 < property聽 name ="user" 聽value ="root" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="password" 聽value ="" /> 聽聽聽聽聽聽聽聽聽聽 聽聽聽聽聽聽聽聽聽< property聽 name ="minPoolSize" 聽value ="2" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="maxPoolSize" 聽value ="20" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="maxIdleTime" 聽value ="1800" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="acquireIncrement" 聽value ="2" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="maxStatements" 聽value ="0" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="initialPoolSize" 聽value ="3" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="idleConnectionTestPeriod" 聽value ="1800" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="acquireRetryAttempts" 聽value ="30" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="breakAfterAcquireFailure" 聽value ="true" /> 聽聽聽聽聽聽聽聽聽< property聽 name ="testConnectionOnCheckout" 聽value ="false" /> 聽聽聽聽聽聽聽聽聽 聽聽聽聽聽聽聽聽聽<!-- 聽 聽聽聽聽聽聽聽聽聽<property聽name="properties"> 聽聽聽聽聽聽聽聽聽聽<props>聽聽聽聽聽聽聽聽聽聽聽聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.minPoolSize">1</prop>聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.maxPoolSize">10</prop>聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.maxIdleTime">1800</prop>聽聽聽聽聽聽聽聽聽聽聽聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.acquireIncrement">2</prop>聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.maxStatements">0</prop>聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.initialPoolSize">2</prop> 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.idleConnectionTestPeriod">1800</prop> 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.acquireRetryAttempts">30</prop> 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.breakAfterAcquireFailure">true</prop> 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="c3p0.testConnectionOnCheckout">true</prop> 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="user">root</prop> 聽聽聽聽聽聽聽聽聽聽聽聽聽聽<prop聽key="password">999999</prop> 聽聽聽聽聽聽聽聽聽聽聽聽聽聽 聽聽聽聽聽聽聽聽聽聽</props> 聽聽聽聽聽聽聽聽聽</property> 聽聽聽聽聽聽聽聽 --> 聽聽聽聽聽聽 </ bean > <!-- 聽Hibernate聽SessionFactory聽 --> < bean聽 id ="sessionFactory" 聽class ="org.springframework.orm.hibernate3.LocalSessionFactoryBean" > 聽聽< property聽 name ="dataSource" 聽ref ="dataSource" /> 聽聽< property聽 name ="mappingDirectoryLocations" > 聽聽聽聽聽聽< list > 聽聽聽< value > classpath:/com/licaionline/domain/ </ value > 聽聽聽聽聽聽</ list > 聽聽</ property > 聽聽< property聽 name ="hibernateProperties" > 聽聽聽< props > 聽聽聽聽聽< prop聽 key ="hibernate.dialect" > org.hibernate.dialect.MySQLDialect </ prop > 聽聽聽聽聽< prop聽 key ="hibernate.show_sql" > true </ prop > 聽聽聽聽聽< prop聽 key ="hibernate.generate_statistics" > true </ prop > 聽聽聽聽聽< prop聽 key ="hibernate.connection.release_mode" > auto </ prop > 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 聽聽聽聽聽 < prop聽 key ="hibernate.autoReconnect" > true </ prop > 聽聽聽聽聽< prop聽 key ="hibernate.cglib.use_reflection_optimizer" > true </ prop > <!-- 聽 聽聽聽聽<prop聽key="hibernate.useUnicode"></prop>聽 聽聽聽聽<prop聽key="hibernate.characterEncoding"></prop> 聽聽聽聽<prop聽key="hibernate.default-lazy-init"></prop> 聽聽聽聽<prop聽key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>聽聽聽聽聽 聽 --> 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<!-- 聽聽聽聽<prop聽key="hibernate.c3p0.acquire_increment">2</prop> 聽聽聽聽<prop聽key="hibernate.c3p0.idle_test_period">1800</prop> 聽聽聽聽<prop聽key="hibernate.c3p0.timeout">1800</prop> 聽聽聽聽<prop聽key="hibernate.c3p0.max_size">30</prop> 聽聽聽聽<prop聽key="hibernate.c3p0.min_size">2</prop> 聽聽聽聽<prop聽key="hibernate.c3p0.max_statements">50</prop>--> 聽聽聽聽聽聽聽聽聽 聽聽聽 </ props > 聽聽</ property > </ bean >
]]> ajax涓巗pring 緇撳悎 http://www.aygfsteel.com/chenlb/archive/2007/03/01/101316.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Thu, 01 Mar 2007 14:05:00 GMT http://www.aygfsteel.com/chenlb/archive/2007/03/01/101316.html http://www.aygfsteel.com/chenlb/comments/101316.html http://www.aygfsteel.com/chenlb/archive/2007/03/01/101316.html#Feedback 2 http://www.aygfsteel.com/chenlb/comments/commentRss/101316.html http://www.aygfsteel.com/chenlb/services/trackbacks/101316.html 杞澆 http://www.javabc.com/Html/javakyjs/java_kyajax/87263814176488.html Spring鐨勯泦鎴愬嚑涔庡紓甯哥畝鍗?鍙渶瑕佹洿鏀歸厤緗枃浠惰屽凡.
欏甸潰鐨勪唬鐮佷笉鐢ㄥ姩錛屼緥濡?br>
]]>
主站蜘蛛池模板:
三原县 |
宿松县 |
清涧县 |
沂源县 |
南城县 |
涞源县 |
亳州市 |
盐山县 |
新安县 |
门头沟区 |
砚山县 |
南涧 |
西平县 |
西吉县 |
中西区 |
鲜城 |
定州市 |
陇南市 |
葵青区 |
东乡 |
榆林市 |
荆门市 |
龙井市 |
阿克苏市 |
柳林县 |
玛多县 |
霞浦县 |
手机 |
东至县 |
西充县 |
梨树县 |
津市市 |
垣曲县 |
浏阳市 |
甘泉县 |
门源 |
伊金霍洛旗 |
博乐市 |
读书 |
丰原市 |
台南市 |