前文已经搭建好了struts2环境,而在struts2的基础上集成spring,则需要加入spring的核心jar包已经相应的struts-spring插件以及commons-logging.jar
1.首先导入所需jar包
2.在web-inf下添加spring配置文件applicationContext.xml
3.在web.xml中加入spring组件:
<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>
4.将建好的action交给spring去管理,即在applicationContext.xml添加action的bean配置
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns ="http://www.springframework.org/schema/beans" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean name="helloWorldAction" class="ssmdemo.HelloWorld" /> </beans> 5.最后修改struts.xml文件
<!-- 告知Struts 2运行时使用Spring来创建对象 --> <constant name="struts.objectFactory" value="spring" /> <package name="struts2" extends="struts-default"> <action name="HelloWorld" class="helloWorldAction"> <result>/HelloWorld.jsp</result> </action> </package>
相关推荐
Hibernate struts2 spring 整合学生信息管理系统源码及文档
对struts2和spring进行整合,希望对想学习该技术的人有一些帮助!
5.struts2_spring struts spring 整合 以上功能包含完整示例代码 Eclipse Java EE IDE for Web Developers. Build id: 20090920-1017 Tomcat6.0 下编译运行通过 struts版本 struts-2.2.3.1 sping版本 spring-...
struts2整合spring、hibernate的jar包
简单的 struts2 spring ibatis 整合架构
自己写的一个SSH整合开发的实例,入门级的,思路清晰非常适合新手。
一个自己做的简单的struts2 和Spring3的一个实例,对初学者有很大帮助,都可以看懂的,呵呵。
struts2 spring hibernate 整合
struts和spring整合的2种方式
使用mysql数据库的struts2 spring hibernate整合简单示例,也可参考我的:“struts2 spring hibernate整合要点、注意点”这篇文档来配置
整合使用最新版本的三大框架(即Struts2、Spring4和Hibernate4),搭建项目架构原型。 项目架构原型:Struts2.3.16 + Spring4.1.1 + Hibernate4.3.6。 此外,还有:log4j、slf4j、junit4、ehcache等知识点。 项目...
Struts2 hibernate spring 整合案例
struts2 spring hibernate 整合过程 希望能对你有帮助,谢谢
struts+spring+hibernate整合
用DelegatingRequestProcessor和DelegatingActionProxy两种方法实现struts和spring的整合,不同的地方就在struts-config.xml文件中,当前文件中DelegatingRequestProcessor是注释的。
struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码struts1 spring ibatis整合项目源码
struts struts hibernate spring 整合 PUBhibernstruts hibernate spring 整合 PUBate spring 整合 PUB
mybatis struts2 spring 整合
SSH(struts2,Hibernate,Spring)整合及测试亲测可用,百分之白亲测可用。
S2SH整合 struts2 spring4 hibernate4