web.xml方式加载Spring
来源:互联网 发布:cad安装软件 编辑:程序博客网 时间:2024/05/16 19:51
使用web.xml方式加载Spring时,获取Spring context的两种方式:
1、servlet方式加载时:
【web.xml】
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext</param-value>
</init-param>
</servlet>
【jsp/servlet】
ServletContext context = getServletContext();
XmlWebApplicationContext applicationContext = (XmlWebApplicationContext) context.getAttribute("org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcherServlet");
DataSource dataSource=(DataSource)applicationContext.getBean("dataSource");
2、listener方式加载时:
【web.xml】
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
【jsp/servlet】
ServletContext context = getServletContext();
WebApplicationContext applicationContext = WebApplicationContextUtils
.getWebApplicationContext(context);
DataSource dataSource=(DataSource)applicationContext.getBean("dataSource");
- web.xml方式加载Spring
- spring的配置文件在web.xml中加载的方式
- 使用web.xml方式加载Spring时,获取Spring context的两种方式
- 使用web.xml方式加载Spring时,获取Spring context的两种方式
- 启动Spring:web.xml方式
- java web 加载Spring --web.xml 篇
- spring 中加载xml配置文件的方式.
- spring 中加载xml配置文件的方式.
- spring 中加载xml配置文件的方式
- Spring中加载XML配置文件的方式
- spring中加载xml配置文件的方式
- spring 中加载xml配置文件的方式
- Spring中加载xml配置文件的方式
- Spring中加载XML配置文件的方式
- spring 中加载xml配置文件的方式
- spring中加载xml配置文件的方式
- Spring加载xml配置文件的方式总结
- spring加载xml文件的方式
- Application操纵Excel
- SQL字符串函数
- C++中参数传递方式讨论
- DB2 数据库常用命令
- web.config优化网站性能设置
- web.xml方式加载Spring
- 网络日志(2009.7.26)
- vs 2005 智能提示 修复方法
- ffmpeg参数解释
- 快速,冒泡,选择排序
- vb发送一串字不被嵌入式系统正确接收的解决办法
- SHELL 正则表达式
- mysql自动备份数据压
- c#开发activex实战