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

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 嘉兴市| 吴旗县| 华亭县| 夹江县| 额济纳旗| 张家川| 静乐县| 华安县| 方正县| 霸州市| 玉田县| 临沧市| 沅陵县| 虎林市| 乌审旗| 平昌县| 监利县| 邮箱| 华宁县| 济阳县| 巴林右旗| 宾阳县| 杂多县| 江阴市| 德令哈市| 田林县| 南木林县| 鞍山市| 江津市| 渭南市| 维西| 彰武县| 新建县| 东安县| 邵阳县| 宿松县| 文水县| 丽江市| 利川市| 甘南县| 裕民县|