Springメインプロファイルのロード

2094 ワード

5.14.4 Convenient  ApplicationContext  instantiation for web applications
You can create  ApplicationContext  instances declaratively by using, for example, a  ContextLoader . Of course you can also create  ApplicationContext  instances programmatically by using one of the  ApplicationContext  implementations.
You can register an  ApplicationContext  using the  ContextLoaderListener  as follows:

contextConfigLocation
/WEB-INF/daoContext.xml /WEB-INF/applicationContext.xml



org.springframework.web.context.ContextLoaderListener

The listener inspects the  contextConfigLocation  parameter. If the parameter does not exist, the listener uses  /WEB-INF/applicationContext.xml  as a default. When the parameter does exist, the listener separates the String by using predefined delimiters (comma, semicolon and whitespace) and uses the values as locations where application contexts will be searched. Ant-style path patterns are supported as well. Examples are  /WEB-INF/*Context.xml  for all files with names ending with "Context.xml", residing in the "WEB-INF"directory, and  /WEB-INF/**/*Context.xml , for all such files in any subdirectory of "WEB-INF".