applicationContext.xml的两种加载方式
2017-03-10 10:01
211 查看
第一种:直接将之放到/WEB-INF下,在web.xml中声明一个listener;
第二种:将之放到classpath下,但是此时要在web.xml中加入,用它来指明你的applicationContext.xml的位置以供web容器来加载。按照Struts2 整合spring的官方给出的档案,写成:
<listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
默认的路径是/WEB-INF/applicationContext.xml
第二种:将之放到classpath下,但是此时要在web.xml中加入,用它来指明你的applicationContext.xml的位置以供web容器来加载。按照Struts2 整合spring的官方给出的档案,写成:
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml </param-value> </context-param>
相关文章推荐
- applicationContext.xml加载的两种方式:
- Spring加载applicationContext.xml实现spring容器管理的几种方式
- spring加载ApplicationContext.xml的四种方式
- spring加载ApplicationContext.xml的四种方式
- ApplicationContext.xml的两种配置方式
- Spring配置文件applicationContext.xml的两种拆分方式
- Spring加载applicationContext.xml的几种方式
- Spring加载配置文件applicationContext.xml的方式
- spring加载ApplicationContext.xml的四种方式
- Spring加载applicationContext.xml的几种方式
- spring ApplicationContext.xml几种加载方式
- Spring加载applicationContext.xml的几种方式
- Spring加载applicationContext.xml应用上下文的方式
- Spring配置文件applicationContext.xml的两种拆分方式
- ApplicationContext.xml中加载properties配置文件
- java se 使用spring框架 解析ApplicationContext.xml的方式
- 使用web.xml方式加载Spring时,获取Spring context的两种方式
- spring加载bean(ClassPathXmlApplicationContext和FileSystemXmlApplicationContext)
- Tomcat启动时,spring加载配置文件applicationContext.xml出错,抛出nested exception is og.xml.sax.SAXParseException
- 将ApplicationContext.xml加载到java内存中