锘??xml version="1.0" encoding="utf-8" standalone="yes"?>自拍自偷一区二区三区,国产综合色在线观看,久久人人97超碰comhttp://www.aygfsteel.com/zhaijianhui/category/11283.html鐮旂┒java鎶鏈?/description>zh-cnFri, 02 Mar 2007 14:47:38 GMTFri, 02 Mar 2007 14:47:38 GMT60spring闆嗘垚鍒皐eb妗嗘灦http://www.aygfsteel.com/zhaijianhui/archive/2006/08/02/61423.html铚樿洓铚樿洓Wed, 02 Aug 2006 15:41:00 GMThttp://www.aygfsteel.com/zhaijianhui/archive/2006/08/02/61423.htmlhttp://www.aygfsteel.com/zhaijianhui/comments/61423.htmlhttp://www.aygfsteel.com/zhaijianhui/archive/2006/08/02/61423.html#Feedback0http://www.aygfsteel.com/zhaijianhui/comments/commentRss/61423.htmlhttp://www.aygfsteel.com/zhaijianhui/services/trackbacks/61423.html鎶妔pring闆嗘垚鍒皐eb妗嗘灦寰堢畝鍗曪紝鍙鍦╳eb.xml閲岄潰鍔犱笂 <context-param> 聽聽聽 <param-name>contextConfigLocation</param-name> 聽聽聽 <param-value>/WEB-INF/applicationContext*.xml</param-value> </context-param> 鎴栬?br /><listener> 聽聽聽 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 濡傛灉涓轟笅闈㈣繖縐嶆柟寮忕殑璇濓紝閭d箞灝辨槸鍔犺澆榛樿鐨勬枃浠?br />/WEB-INF/applicationContext.xml 榪欎釜鍦?br />org.springframework.web.context.support.XmlWebApplicationContext綾婚噷闈㈠畾涔夌殑,,閮ㄥ垎浠g爜錛?br />/** 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鎴戜滑灝卞彲浠ラ氳繃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.