PIXNET Logo登入

大笨鳥的私房菜

跳到主文

大笨鳥於程設這條不歸路上遇到的各式問題與心得

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 4月 02 週二 201314:40
  • 在使用 Spring 的 Web 專案中的一般類別,如何取得由 Spring 實例化出來的物件

在使用 Spring 的 Web 專案中的一般類別 (即未宣告在 applicationContext.xml 的類別),如何取得由 Spring 實例化出來的物件?

請依照下例步驟執行:

取得 javax.servlet.ServletContext 物件
如果是 struts2 專案,可使用【 org.apache.struts2.ServletActionContext.getServletContext() 】來取得。
取得 org.springframework.context.ApplicationContext 物件
使用【 org.springframework.web.context.support.WebApplicationContextUtils 】類別來取得 WebApplicationContext (繼承自 ApplicationContext) 物件。如下:
WebApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); // 將第 1 步取得的 ServletContext 物件傳入
透過 ApplicationContext 物件即可取得由 Spring 實例化出來的物件了
例如:HelloService helloService = (HelloService) ac.getBean("helloService");
(繼續閱讀...)
文章標籤

大笨鳥 發表在 痞客邦 留言(0) 人氣(166)

  • 個人分類:史匹靈(Spring)
▲top
  • 9月 29 週二 200923:13
  • org.springframework.dao.DataAccessResourceFailureException: Could not create Oracle LOB

這只是簡記~ 之後有空再更新當我們需要使用 CLOB 或 BLOB 的操作時 (Oralce 資料庫),在 9i 的 jdbc driver 下,我們需要使用 Spring 的 LobHandler 與 NativeJdbcExtractor 這兩種介面互相搭配。因此在 Spring 的配置檔中,我們會寫上 
 
<bean class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor" lazy-init="true" id="nativeJdbcExtractor" />
<bean class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true" id="oracleLobHandler">
(繼續閱讀...)
文章標籤

大笨鳥 發表在 痞客邦 留言(0) 人氣(325)

  • 個人分類:史匹靈(Spring)
▲top
1

熱門文章

  • (21,683)Oracle 好用 Fuction 介紹 - ROW_NUMBER
  • (7,981)鎖!滑鼠右鍵、功能鍵、組合鍵……
  • (3,609)取代 eval 的方式
  • (2,818)如化在宣告List 與 Map 類別時順便初始化?
  • (1,981)使用 createElement 插入 text 元件到 form 的陷阱
  • (1,272)任意竄改別人的網頁(適用IE與FireFox)
  • (1,193)使用JSP輸出Excel檔常見問題
  • (523)這擺洗 firefox:消失的輸入框游標
  • (321)Oracle 好用 Fuction 介紹 - RANK
  • (291)Tomcat + DBCP 在連線閒置一段時間後,會丟出 No operation allowed after connection closed 問題的解決方式

文章分類

toggle WebService (1)
  • Axis (3)
toggle DHTML (3)
  • YUI3 (1)
  • 吸A死A死 (2)
  • 吃肉是鬼 (32)
toggle Java (2)
  • 吃肉韋伯 (3)
  • 吃肉 (5)
toggle 架構 (3)
  • 死踹死1.x (1)
  • 史匹靈(Spring) (2)
  • 死踹死2.x (7)
toggle 資料庫 (2)
  • SQL (1)
  • Oracle (4)
  • 未分類文章 (1)

最新文章

  • 各瀏覽器的 navigator.userAgent 傳回來的值
  • 在使用 Spring 的 Web 專案中的一般類別,如何取得由 Spring 實例化出來的物件
  • 一鍵下載 - Chrome 限定
  • Test Geolocation API
  • DOM element 屬性 scroll、client 與 offset 的差異(以 width 為例)
  • YUI Builder 簡介與安裝
  • 當 Html Tag 被包在 <a> 之中時,使用 innerHTML 在 Firefox 上的詭異現象與解決方式
  • Struts 2.1 以上版本,在 xml 配置檔的 include tag 已經可以用萬用字元了
  • 解決使用 AXIS Client 呼叫 AXIS2 Web Service 傳檔案時發生的錯誤
  • WebService 的傳遞檔案方式 -- DataHandler (範例使用 AXIS)

最新留言

  • [19/08/27] 訪客 於文章「Oracle 好用 Fuction 介紹...」留言:
    感謝您...
  • [15/06/22] Jacqueline 於文章「各瀏覽器的 navigator.user...」留言:
    sexy babes cam to cam phone se...
  • [14/03/07] dominikaz 於文章「各瀏覽器的 navigator.user...」留言:
    A mature person free webcams e...
  • [14/02/27] Ivonna 於文章「各瀏覽器的 navigator.user...」留言:
    http://www.hugcams.com/live-se...
  • [12/11/01] aaa 於文章「Test Geolocation API...」留言:
    你好可以請問一下 你那個Geolocation 的按鈕...
  • [10/10/08] somebaby 於文章「測試 SyntaxHighlighter...」留言:
    謝謝你 我測試成功了...
  • [10/10/04] somebabyTina 於文章「測試 SyntaxHighlighter...」留言:
    請問如何在Pixnet 上使用 syntaxhighligh...

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: