posts - 122,  comments - 25,  trackbacks - 0
          在Servlet或者filter或者Listener中使用spring的IOC容器的方法是:
          WebApplicationContext webApplicationContext =
              WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext()); 

          由于spring是注入的對象放在ServletContext中的,所以可以直接在ServletContext取出WebApplicationContext 對象:
          WebApplicationContext webApplicationContext =
              (WebApplicationContext) servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);

          事實上WebApplicationContextUtils.getWebApplicationContext方法就是使用上面的代碼實現(xiàn)的,建議使用上面上面的靜態(tài)方法
          posted on 2007-04-25 17:08 josson 閱讀(518) 評論(0)  編輯  收藏 所屬分類: Spring
          <2007年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 万山特区| 刚察县| 蓬莱市| 莆田市| 高台县| 浦县| 将乐县| 济源市| 保康县| 广汉市| 越西县| 鄢陵县| 滕州市| 科技| 扎囊县| 吉安市| 慈溪市| 罗城| 鹤壁市| 铜鼓县| 江城| 大洼县| 郴州市| 太白县| 义乌市| 苗栗县| 池州市| 靖边县| 大连市| 光山县| 商丘市| 余庆县| 兴海县| 保亭| 普兰县| 邻水| 大渡口区| 天峨县| 桓台县| 永和县| 连南|