整合的方法有两种.我这里只写一种了
常用的sturts整合spring
先在web.xml中添加
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 对Spring容器进行实例化 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
我上面写的是xml文件直接放到src目录下的
如果你是放在web-inf下
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/applicationContext.xml</param-value>
</context-param>
<!-- 对Spring容器进行实例化 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
然后在action中从spring容器中取对象
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServlet().getServletContext());
UserService userService = (UserService) wac.getBean("personService");
详细例子见附件.由于比较大.我分开发了.jar包单发
分享到:
相关推荐
Spring 整合 Struts,很强大
使用Spring整合Struts编写多页面用户注册模块 使用Spring整合Struts编写多页面用户注册模块
Spring集成struts以及hibernate jar包 所有的都在里面 需要的可以下载
三大框架集成及两两集成的jar包,spring集成hibernate的jar包以及spring集成struts2的jar包已经单独打包
spring整合struts.rar
Spring整合集成Struts1.2最简单例子
spring整合struts2与hibernate核心配置文件
spring框架整合struts框架时必需的类库文件
Spring 整合 Struts2 详解
Spring整合Struts2 SSH 最少jar包
此资源中包涵了spring整合struts和hibernate的所有资源,在做项目时只要在工程中引入该jar包就行,不用在eclipse或Myeclipse中加载strut与hibernate的资源了,挺有用的!
Spring整合Struts 的详细开发文档 ,实战中的最佳排挡,适合一定开发经验的人群
深层次理解Spring整合Struts2开发原理,更有效地组织开发过程
Spring集成Struts的三种方案 详细 给力
Spring与struts整合主要有三种方式,通过Spring的ActionSupport类,通过Spring的DelegatingRequestProcessor类、通过Spring的DelegatingActionProxy类。
关于spring集成Struts+Hibernate的详细介绍,欢迎大家借鉴!
一个spring整合struts2的完整实例源码
SSH笔记-Spring整合Struts2,作用是使用 IOC 容器来管理 Struts2 的 Action
使用Spring集成struts2、ibatis、poi实现的增删改查功能,包括采用jquery实现的无刷新查询机分页、dwr实现的两级联动、以及采用poi动态将数据库数据导出成excel,本demo采用mysql数据库,附有建表sql,项目导入...