web中servletcontext和applicationContext

來源:互聯網
上載者:User

標籤:資料   res   依賴關係   ssi   ext.get   介面   部署   war   log   

參看:http://www.cnblogs.com/isisbenben/p/5594323.html

servletContext和ApplicationContext有什麼區別

servletContext:是web容器的東西,一個webapp一個,比session作用範圍要大,從中得到很多資訊,比如:工程部署的路徑目錄。

ApplicationContext:是Spring的東西,spring通過這個讀取xml設定檔來new bean的(應用上下文)

作用:(1)讀取bean設定檔,管理bean載入,執行個體化,維護bean之間的依賴關係,負責bean的周期聲明

  (2)提供完整的架構功能,例如:a.國際化支援  b .資源訪問:Resource rs =ctx.getResource("classpath:config.properties"); c .事件傳遞:通過實現ApplicationContextAware介面。

======== =========================================================================================

ServletContext與application的異同

兩者本質上是一樣的,相當於建立了2個不同名稱的變數。

在servlet中ServletContext就是application對象:

ServletContext application =null;

application =pageContext.getServletContext();

差異:

兩者的區別就是application用在jsp中,servletContext用在servlet中。application和page、request、session都是jsp中的內建對象,在後台用ServletContext儲存的屬性資料可以用application對象獲得。

web中servletcontext和applicationContext

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.