<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    探索與發現

    研究java技術

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      83 隨筆 :: 0 文章 :: 109 評論 :: 0 Trackbacks

    把spring集成到web框架很簡單,只要在web.xml里面加上
    <context-param>
    ??? <param-name>contextConfigLocation</param-name>
    ??? <param-value>/WEB-INF/applicationContext*.xml</param-value>
    </context-param>
    或者
    <listener>
    ??? <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    如果為下面這種方式的話,那么就是加載默認的文件
    /WEB-INF/applicationContext.xml
    這個在
    org.springframework.web.context.support.XmlWebApplicationContext類里面定義的,,部分代碼:
    /** Default config location for the root context */
    ?public static final String DEFAULT_CONFIG_LOCATION = "/WEB-INF/applicationContext.xml";

    ?/** Default prefix for building a config location for a namespace */
    ?public static final String DEFAULT_CONFIG_LOCATION_PREFIX = "/WEB-INF/";

    ?/** Default suffix for building a config location for a namespace */
    ?public static final String DEFAULT_CONFIG_LOCATION_SUFFIX = ".xml";


    Once the context files are loaded, Spring creates a WebApplicationContext object based on the bean definitions and puts it into the ServletContext.
    這樣我們就可以直接用ServletContext獲取自己想要的參數的,,

    All Java web frameworks are built on top of the Servlet API, so you can use the following code to get the ApplicationContext that Spring created.

    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);

    通過WebApplicationContext我們就可以通過bean的名字獲取它的實例了
    The WebApplicationContextUtils class is for convenience, so you don't have to remember the name of the ServletContext attribute. Its getWebApplicationContext() method will return null if an object doesn't exist under the WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE key. Rather than risk getting NullPointerExceptions in your application, it's better to use the getRequiredWebApplicationContext() method. This method throws an Exception when the ApplicationContext is missing.

    Once you have a reference to the WebApplicationContext, you can retrieve beans by their name or type. Most developers retrieve beans by name, then cast them to one of their implemented interfaces.

    Fortunately, most of the frameworks in this section have simpler ways of looking up beans. Not only do they make it easy to get beans from the BeanFactory, but they also allow you to use dependency injection on their controllers. Each framework section has more detail on its specific integration strategies.

    posted on 2006-08-02 23:41 蜘蛛 閱讀(628) 評論(0)  編輯  收藏 所屬分類: spring

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲一区二区三区不卡在线播放| 久久精品国产精品亚洲人人| 亚洲日韩中文字幕无码一区| 俄罗斯极品美女毛片免费播放| 中文在线观看免费网站| 亚洲AV乱码久久精品蜜桃| 色se01短视频永久免费| 精品国产亚洲第一区二区三区| 亚洲乱码一区二区三区在线观看| 麻豆国产精品免费视频| 一区二区三区视频免费观看| 亚洲系列国产精品制服丝袜第| 亚洲国产成人精品无码久久久久久综合 | 男女午夜24式免费视频| 伊人久久五月丁香综合中文亚洲| 国产精品亚洲w码日韩中文| 永久免费毛片在线播放| 青青操在线免费观看| 日韩色日韩视频亚洲网站| 免费看一级高潮毛片| 亚洲国产人成在线观看| 久久久影院亚洲精品| 麻豆亚洲av熟女国产一区二| 久久久久亚洲AV无码专区网站| 亚洲综合另类小说色区色噜噜| 曰韩亚洲av人人夜夜澡人人爽 | 国产成人无码免费看片软件| 在线观看亚洲免费| 亚洲人成人网毛片在线播放| 亚洲精品影院久久久久久| 亚洲另类视频在线观看| 精品韩国亚洲av无码不卡区| 2022国内精品免费福利视频 | 亚洲熟女精品中文字幕| 免费国产黄网站在线观看动图| www.av在线免费观看| 久久精品私人影院免费看| 114一级毛片免费| 无码国产精品一区二区免费3p| 两个人看www免费视频| 免费看美女裸露无档网站|