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 閱讀(521) 評論(0)  編輯  收藏 所屬分類: Spring
          <2007年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 临邑县| 盐亭县| 彰武县| 金秀| 蒲江县| 阳高县| 青州市| 普定县| 五台县| 灵宝市| 灵台县| 喀喇沁旗| 邹平县| 郯城县| 广安市| 安仁县| 涿州市| 隆德县| 平山县| 新乐市| 织金县| 衡南县| 太湖县| 永年县| 车致| 丹巴县| 锡林浩特市| 故城县| 巩义市| 清水河县| 北碚区| 郸城县| 墨脱县| 临汾市| 聊城市| 蓝山县| 六枝特区| 英超| 恭城| 图木舒克市| 象山县|