加载spring配置文件的常用三种方法
2013-03-08 22:52
609 查看
http://weijie.blog.51cto.com/340746/66502
1方法(web.xml)
<web-app>
<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-app>
2方法(web.xml)
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml</param-value>
</context-param>
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
3方法在(struts-config.xml)中加载
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml,
/WEB-INF/action-servlet.xml"/>
</plug-in>
本文出自 “魏杰的技术专栏” 博客,请务必保留此出处http://weijie.blog.51cto.com/340746/66502
1方法(web.xml)
<web-app>
<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-app>
2方法(web.xml)
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml</param-value>
</context-param>
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
3方法在(struts-config.xml)中加载
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml,
/WEB-INF/action-servlet.xml"/>
</plug-in>
本文出自 “魏杰的技术专栏” 博客,请务必保留此出处http://weijie.blog.51cto.com/340746/66502
相关文章推荐
- 加载spring配置文件的常用三种方法
- 加载spring配置文件的常用三种方法
- 加载spring配置文件的常用三种方法
- 加载spring配置文件的常用三种方法
- 加载Spring配置文件常用的三种方法
- Spring通过类方法加载配置文件
- 【log4j2 加载配置文件】 加载配置文件的三种方法
- SSH学习九 依赖注入及加载Spring配置文件的方法
- Spring加载配置文件的几种方法(出现错误的时候可以查看)
- Spring的ApplicationContext加载多个配置文件的三种方式
- Spring加载配置文件的3种方法
- Spring中加载xml配置文件的常用的几种方式
- Spring加载配置文件的三种方式
- java一般加载配置文件时常用的方法
- Spring加载配置文件的三种方式
- 在Maven项目中加载spring中的bean的配置xml文件会提示找不到解决方法
- Spring加载配置文件的几种方法
- spring 中加载xml配置文件的方法
- Spring配置文件的三种方法(创建测试类Test.java)
- Spring (一) 加载配置文件,实例化类, 三种实例化bean的方式