锘??xml version="1.0" encoding="utf-8" standalone="yes"?>在线免费黄色毛片,国产福利免费在线观看,青青草这里只有精品http://www.aygfsteel.com/chenlb/category/20284.html濂借鎬т笉濡傜儌絎斿ご!zh-cnSat, 27 Oct 2007 08:35:22 GMTSat, 27 Oct 2007 08:35:22 GMT60spring 渚濊禆娉ㄥ叆鍒扮洿鎺ew 瀵硅薄http://www.aygfsteel.com/chenlb/archive/2007/10/27/156359.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Sat, 27 Oct 2007 08:31:00 GMThttp://www.aygfsteel.com/chenlb/archive/2007/10/27/156359.htmlhttp://www.aygfsteel.com/chenlb/comments/156359.htmlhttp://www.aygfsteel.com/chenlb/archive/2007/10/27/156359.html#Feedback0http://www.aygfsteel.com/chenlb/comments/commentRss/156359.htmlhttp://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><link>http://www.aygfsteel.com/chenlb/archive/2007/08/20/138075.html</link><dc:creator>嫻佹氮姹?/dc:creator><author>嫻佹氮姹?/author><pubDate>Mon, 20 Aug 2007 03:39:00 GMT</pubDate><guid>http://www.aygfsteel.com/chenlb/archive/2007/08/20/138075.html</guid><wfw:comment>http://www.aygfsteel.com/chenlb/comments/138075.html</wfw:comment><comments>http://www.aygfsteel.com/chenlb/archive/2007/08/20/138075.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/chenlb/comments/commentRss/138075.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/chenlb/services/trackbacks/138075.html</trackback:ping><description><![CDATA[    鏁版嵁婧愶細<br> <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: #000000">     </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">bean </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="dataSource"</span><span style="COLOR: #ff0000"> class</span><span style="COLOR: #0000ff">="org.apache.commons.dbcp.BasicDataSource"</span><span style="COLOR: #ff0000"> destroy-method</span><span style="COLOR: #0000ff">="close"</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>         </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="driverClassName"</span><span style="COLOR: #ff0000"> value</span><span style="COLOR: #0000ff">="com.mysql.jdbc.Driver"</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>         </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="url"</span><span style="COLOR: #ff0000"> value</span><span style="COLOR: #0000ff">="jdbc:mysql://localhost:3306/study"</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>         </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="username"</span><span style="COLOR: #ff0000"> value</span><span style="COLOR: #0000ff">="root"</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>         </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="password"</span><span style="COLOR: #ff0000"> value</span><span style="COLOR: #0000ff">=""</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>     </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">bean</span><span style="COLOR: #0000ff">></span></div> <br>    浜嬪姟綆$悊鑰咃細<br> <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: #000000">    </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">bean </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="transactionManager"</span><span style="COLOR: #ff0000"> class</span><span style="COLOR: #0000ff">="org.springframework.jdbc.datasource.DataSourceTransactionManager"</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="dataSource"</span><span style="COLOR: #ff0000"> ref</span><span style="COLOR: #0000ff">="dataSource"</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>    </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">bean</span><span style="COLOR: #0000ff">></span></div> <br>    琚鐞嗙殑瀵硅薄錛?br> <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://www.aygfsteel.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">bean </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="myBusinessObjectTarget"</span><span style="COLOR: #ff0000"> class</span><span style="COLOR: #0000ff">="mybusiness.MyBusinessObject"</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">bean</span><span style="COLOR: #0000ff">></span></div> <br>    浜嬪姟鎬т唬鐞嗗璞★細<br> <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: #000000">    </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">bean </span><span style="COLOR: #ff0000">id</span><span style="COLOR: #0000ff">="myBusinessObject"</span><span style="COLOR: #ff0000"> class</span><span style="COLOR: #0000ff">="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="transactionManager"</span><span style="COLOR: #ff0000"> ref</span><span style="COLOR: #0000ff">="transactionManager"</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="target"</span><span style="COLOR: #ff0000"> ref</span><span style="COLOR: #0000ff">="myBusinessObjectTarget"</span><span style="COLOR: #0000ff">></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>        </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">property </span><span style="COLOR: #ff0000">name</span><span style="COLOR: #0000ff">="transactionAttributes"</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>            </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">props</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>                </span><span style="COLOR: #0000ff"><</span><span style="COLOR: #800000">prop </span><span style="COLOR: #ff0000">key</span><span style="COLOR: #0000ff">="myBusinessMethod"</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>                    PROPAGATION_REQUIRED,-MyCheckedException<br>                </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">prop</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>            </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">props</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>        </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">property</span><span style="COLOR: #0000ff">></span><span style="COLOR: #000000"><br>    </span><span style="COLOR: #0000ff"></</span><span style="COLOR: #800000">bean</span><span style="COLOR: #0000ff">></span></div> 璇存槑錛?MyCheckedException琛ㄧず鎶涘嚭姝ゅ甯告椂鍥炴粴錛?MyCheckedException琛ㄧず鎶涘嚭姝ゅ甯告椂鎻愪氦銆?br><br>    MyBusinessObject錛?br> <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: #0000ff">package</span><span style="COLOR: #000000"> mybusiness;<br><br></span><span style="COLOR: #008000">/**</span><span style="COLOR: #008000"><br> * <br> * 2007-8-20 涓婂崍11:26:28<br> * </span><span style="COLOR: #808080">@author</span><span style="COLOR: #008000"> chenlb<br> </span><span style="COLOR: #008000">*/</span><span style="COLOR: #000000"><br></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000"> MyBusinessObject {<br><br>    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000"> myBusinessMethod() </span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000"> MyCheckedException {<br>        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> do some resource access<br>        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> return some result object or throw MycheckedException</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">    }<br>}</span></div> <br><br>澹版槑寮忎簨鍔$殑鍏朵腑涓縐嶅艦寮忋俕_^ <img src ="http://www.aygfsteel.com/chenlb/aggbug/138075.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/chenlb/" target="_blank">嫻佹氮姹?/a> 2007-08-20 11:39 <a href="http://www.aygfsteel.com/chenlb/archive/2007/08/20/138075.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>spring 瀵?conection 鐨勪簨鍔?/title><link>http://www.aygfsteel.com/chenlb/archive/2007/08/20/138071.html</link><dc:creator>嫻佹氮姹?/dc:creator><author>嫻佹氮姹?/author><pubDate>Mon, 20 Aug 2007 03:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/chenlb/archive/2007/08/20/138071.html</guid><wfw:comment>http://www.aygfsteel.com/chenlb/comments/138071.html</wfw:comment><comments>http://www.aygfsteel.com/chenlb/archive/2007/08/20/138071.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/chenlb/comments/commentRss/138071.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/chenlb/services/trackbacks/138071.html</trackback:ping><description><![CDATA[<p>    spring 瀵?JdbcTemplate……鐨勪簨鍔$鐞嗕笉鐢ㄦ媴蹇冦傚氨鏄鐩存帴Jdbc瀹炵幇鐨凞ao浜嬪姟綆$悊鏈夌偣灝忛棶棰橈紝濡傦細鎴戠洿鎺ワ紝鐢╠ataSource.getConnection()銆俿pring鏄鐞嗕笉浜嗕簨鍔$殑銆傚師鍥犳槸Jdbc瀹炵幇鐨凞ao閲岀殑connection鏄嚜鍔ㄦ彁浜ょ殑銆傝鏀圭敤緇忚繃spring 澶勭悊榪囩殑connection = DataSourceUtil.getConnection(dataSource);鎵嶈銆?br>    鎴戣繖鏈変釜渚嬪瓙鈥斺旂敤鎴鋒敞鍐岋紝鏈夊浠姐傚彧鏄緥瀛愯屼笖銆?br>    涓嬮潰鏄師濮嬬殑Dao瀹炵幇錛?br>澶囦喚鏂規(guī)硶錛?/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: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> User backUp(User user) </span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000"> SQLException {<br>        Connection conn </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> dataSource.getConnection();<br>        </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> {<br>            PreparedStatement pstmt </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> conn.prepareStatement(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">insert into user(name) values (?)</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>            pstmt.setString(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, user.getName()</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>            pstmt.executeUpdate();<br>            <br>            pstmt </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> conn.prepareStatement(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">select last_insert_id()</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>            ResultSet rs </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> pstmt.executeQuery();<br>            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(rs </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> rs.next()) {<br>                user.setUId(rs.getInt(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">));<br>            }<br>        } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (SQLException e) {<br>            </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: #000000">            </span><span style="COLOR: #0000ff">throw</span><span style="COLOR: #000000"> e;<br>        } </span><span style="COLOR: #0000ff">finally</span><span style="COLOR: #000000"> {<br>            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(conn </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: #0000ff">try</span><span style="COLOR: #000000"> {<br>                    conn.close();<br>                } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (SQLException e) {<br>                                System.out.println(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">鏁版嵁搴撹繛鎺ュ叧闂け璐?</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>                }<br>            }<br>        }<br>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> user;<br>    }</span></div> <br>鐜板湪瑕佹敼鎴愶細<br> <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: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> User backUp(User user) </span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000"> SQLException {<br>        Connection conn </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> DataSourceUtils.getConnection(dataSource);<br>        </span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"> {<br>            PreparedStatement pstmt </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> conn.prepareStatement(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">insert into user(name) values (?)</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>            pstmt.setString(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, user.getName()</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>            pstmt.executeUpdate();<br>            <br>            pstmt </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> conn.prepareStatement(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">select last_insert_id()</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>            ResultSet rs </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> pstmt.executeQuery();<br>            </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(rs </span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000"> rs.next()) {<br>                user.setUId(rs.getInt(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">));<br>            }<br>        } </span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000"> (SQLException e) {<br>            </span><span style="COLOR: #0000ff">throw</span><span style="COLOR: #000000"> e;<br>        } </span><span style="COLOR: #0000ff">finally</span><span style="COLOR: #000000"> {<br>            DataSourceUtils.releaseConnection(conn, dataSource);<br>        }<br>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> user;<br>    }</span></div> <br>鐒跺悗浣犲湪閫昏緫灞傚氨鍙互鐢╯pring鐨勪換浣曟柟寮忕鐞嗕簨鍔′簡銆?br>濡傦細娉ㄥ唽<br> <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: #000000">    </span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000"> User register(User user) </span><span style="COLOR: #0000ff">throws</span><span style="COLOR: #000000"> SQLException {<br>        userDao.backUp(user);<br>        userDao.insert(user);<br>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> user;<br>    }</span></div> <br><br> <img src ="http://www.aygfsteel.com/chenlb/aggbug/138071.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/chenlb/" target="_blank">嫻佹氮姹?/a> 2007-08-20 11:22 <a href="http://www.aygfsteel.com/chenlb/archive/2007/08/20/138071.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>jsp 涓?寮曠敤 spring 綆$悊鐨凚eanhttp://www.aygfsteel.com/chenlb/archive/2007/08/13/136444.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Mon, 13 Aug 2007 09:22:00 GMThttp://www.aygfsteel.com/chenlb/archive/2007/08/13/136444.htmlhttp://www.aygfsteel.com/chenlb/comments/136444.htmlhttp://www.aygfsteel.com/chenlb/archive/2007/08/13/136444.html#Feedback0http://www.aygfsteel.com/chenlb/comments/commentRss/136444.htmlhttp://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><link>http://www.aygfsteel.com/chenlb/archive/2007/05/08/115969.html</link><dc:creator>嫻佹氮姹?/dc:creator><author>嫻佹氮姹?/author><pubDate>Tue, 08 May 2007 07:44:00 GMT</pubDate><guid>http://www.aygfsteel.com/chenlb/archive/2007/05/08/115969.html</guid><wfw:comment>http://www.aygfsteel.com/chenlb/comments/115969.html</wfw:comment><comments>http://www.aygfsteel.com/chenlb/archive/2007/05/08/115969.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/chenlb/comments/commentRss/115969.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/chenlb/services/trackbacks/115969.html</trackback:ping><description><![CDATA[鏀墮泦浜庣綉緇?br><br>     棣栧厛錛岄渶瑕佸皢緇ф壙浜哠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()蹇呴』鑰冭檻鍒拌繖縐嶆儏鍐點? <img src ="http://www.aygfsteel.com/chenlb/aggbug/115969.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/chenlb/" target="_blank">嫻佹氮姹?/a> 2007-05-08 15:44 <a href="http://www.aygfsteel.com/chenlb/archive/2007/05/08/115969.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>spring with c3p0http://www.aygfsteel.com/chenlb/archive/2007/03/18/104575.html嫻佹氮姹?/dc:creator>嫻佹氮姹?/author>Sun, 18 Mar 2007 09:06:00 GMThttp://www.aygfsteel.com/chenlb/archive/2007/03/18/104575.htmlhttp://www.aygfsteel.com/chenlb/comments/104575.htmlhttp://www.aygfsteel.com/chenlb/archive/2007/03/18/104575.html#Feedback0http://www.aygfsteel.com/chenlb/comments/commentRss/104575.htmlhttp://www.aygfsteel.com/chenlb/services/trackbacks/104575.htmlhttp://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 GMThttp://www.aygfsteel.com/chenlb/archive/2007/03/01/101316.htmlhttp://www.aygfsteel.com/chenlb/comments/101316.htmlhttp://www.aygfsteel.com/chenlb/archive/2007/03/01/101316.html#Feedback2http://www.aygfsteel.com/chenlb/comments/commentRss/101316.htmlhttp://www.aygfsteel.com/chenlb/services/trackbacks/101316.html杞澆 http://www.javabc.com/Html/javakyjs/java_kyajax/87263814176488.html

Spring鐨勯泦鎴愬嚑涔庡紓甯哥畝鍗?鍙渶瑕佹洿鏀歸厤緗枃浠惰屽凡.

欏甸潰鐨勪唬鐮佷笉鐢ㄥ姩錛屼緥濡?br>

doc.simple-spring.jsp
< script language = " javascript " >
var  springEndPoint = " <%=request.getContextPath()%>/remoting/Spring-buffalo " ;
function
 pageMethod() {
 
var  buffalo  =   new
 Buffalo(springEndPoint);
 buffalo.remoteCall(
" yourObject.yourMethod " ,[],  function
(reply) {
  
var  Obj  =
 reply.getResult();
 })
}
</ script >


web閮ㄧ講鎻忚堪鏂囦歡
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    
<display-name>Buffalo Web Remoting Demostration Application</display-name>
    
<context-param>
        
<param-name>contextConfigLocation</param-name>
        
<param-value>
            /WEB-INF/applicationContext.xml
        
</param-value>
    
</context-param>
    
<servlet>
        
<servlet-name>context</servlet-name>
        
<servlet-class>                   org.springframework.web.context.ContextLoaderServlet                </servlet-class>
        
<load-on-startup>1</load-on-startup>
    
</servlet>
    
    
<servlet>
        
<servlet-name>remoting</servlet-name>
        
<servlet-class>                  org.springframework.web.servlet.DispatcherServlet                </servlet-class>
        
<load-on-startup>4</load-on-startup>
    
</servlet>
        
<servlet-mapping>
        
<servlet-name>remoting</servlet-name>
        
<url-pattern>/remoting/*</url-pattern>
    
</servlet-mapping>    
</web-app>

浠ュ墠鐨刡uffalo-service.properties鏂囦歡鍒欎笉鐢?applicationContext.xml鎵鏇夸唬涔?
鍏朵腑寮曠敤鍒扮殑bean鍙互鏄換鎰忚Spring鎵樼鐨刡ean.榪欎釜Controller鍙互琚換鎰忎換鎰忔柟寮忕殑ServletDispather璋冪敤
.

applicationContext.xml
<beans>    
    
<bean name="simpleService" class="net.buffalo.demo.simple.SimpleService">         </bean>
    
<bean name="numberService" class="net.buffalo.demo.numberguess.NumberGuessService">        </bean>    
</beans>

remoting-servlet.xml
<beans>
  
<bean name="/Spring-buffalo" class="net.buffalo.spring.BuffaloServiceExporter">
    
<property name="services">
            
<map>
                
<entry key="simpleService">
                    
<ref bean="simpleService"/>
                
</entry>
        
<entry key="numberService">
                    
<ref bean="numberService"/>
                
</entry>
            
</map>
        
</property></bean></beans>




]]>
主站蜘蛛池模板: 三原县| 宿松县| 清涧县| 沂源县| 南城县| 涞源县| 亳州市| 盐山县| 新安县| 门头沟区| 砚山县| 南涧| 西平县| 西吉县| 中西区| 鲜城| 定州市| 陇南市| 葵青区| 东乡| 榆林市| 荆门市| 龙井市| 阿克苏市| 柳林县| 玛多县| 霞浦县| 手机| 东至县| 西充县| 梨树县| 津市市| 垣曲县| 浏阳市| 甘泉县| 门源| 伊金霍洛旗| 博乐市| 读书| 丰原市| 台南市|