spring整合web
来源:互联网 发布:change my mac中文版 编辑:程序博客网 时间:2024/06/01 10:33
1. Spring整合WEB需要引入spring-web-4.2.4.RELEASE.jar包
2. 在web.xml中配置监听器并且读取配置文件:
<!-- 配置Spring的核心监听器: -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
3. 修改Action的代码
ServletContext servletContext = ServletActionContext.getServletContext();
// 需要使用WEB的工厂的方式
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
context.getBean("id名");
调用目标对象的方法;
2. 在web.xml中配置监听器并且读取配置文件:
<!-- 配置Spring的核心监听器: -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
3. 修改Action的代码
ServletContext servletContext = ServletActionContext.getServletContext();
// 需要使用WEB的工厂的方式
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
context.getBean("id名");
调用目标对象的方法;
阅读全文
0 0
- spring---整合Junit,整合web
- Spring-整合Web
- spring整合web
- Spring整合web项目
- spring整合web项目
- Spring整合web
- spring整合web项目
- Spring与Web整合
- Spring整合web项目
- spring整合web
- Spring整合web项目原理
- Spring 整合web项目原理
- spring整合web详细介绍
- Spring整合web项目原理
- Spring整合Web,Mybatis,Hibernate
- Spring如何整合WEB框架
- Spring整合Web项目原理
- Spring整合Web项目原理
- 解决装了Ubuntu耳机没有声音的问题(外放有声音)
- eclipse
- 阿里巴巴CTO行癫:阿里双11是世界互联网技术的超级工程
- task_delay
- Mysql 5.x安装卡在最后一步配置执行界面中
- spring整合web
- 自己实现一个简单的读写锁
- 直击阿里双11神秘技术:PB级大规模文件分发系统“蜻蜓”
- C++ Socket编程步骤
- C# 使用Semaphore(信号量)控制多线程
- 机器学习之基础理论相关了解
- 邬迪:乌云完成了使命 | 乌云回忆录(一)
- 华为研发工程师编程题:明明的随机数 [python]
- 异常(2)-- UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/项目包名