struts2.3.3整合spring3.3.1
来源:互联网 发布:toastr.js 编辑:程序博客网 时间:2024/05/01 05:19
struts2.3.3整合spring3.1.1
一、整合jar包
(1)添加struts2插件jar包 struts2-spring-plugin-2.1.6.jar
(2)添加struts2的jar
(3)添加spring的jar
(4)去掉重复及缺少的部份commons jar
整合完毕后jar包截图为:
二、在src下创建applicationContext.xml(即:beans.xml)、struts.xml
三、配置web.xml
(1)配置spring监听器及配置文件加载路径
<!-- 通过监听器监听spring,当服务器一启动时spring就进行加载 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value></context-param> <!-- 如果有多个文件,并且是放在WEB-INF可通过如下写法 <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value></context-param> --><listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
(2)配置struts2的filter
<!-- 配置struts2的filter --><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter>
四、applicationContext.xml配置各bean之间的依赖关系
<bean id="loginAction" class="com.cms.admin.action.LoginAction" scope="prototype"> <property name="loginServicesImpl" ref="loginServicesImpl"></property> </bean> <bean id="loginServicesImpl" class="com.cms.admin.services.impl.LoginServicesImpl" ></bean>
五、配置struts.xml
<package name="login" namespace="/" extends="struts-default"> <action name="loginAction" class="loginAction"> <result name="success">/success.jsp</result> <result name="fail">/fail.jsp</result> </action> </package>
注:上图的class,并不是action的实际类,而是在applicationContext.xml里配置的bean的 id名子。
源码可以通过如下地址来下载:
"http://115.com/file/dpgfhudq#struts2_spring.rar
在后期的开发中发现一个版本的问题:在上面提供的包中,发现高版本的hibernate的jar 已经和annotation的合并了,所以要去掉 hibernate-commons-annotations.jar
和hibernate-annotations.jar;asm-3.3.jar和spring自代的asm包也有冲突,所以这个包也要去掉。
- struts2.3.3整合spring3.3.1
- struts2 spring3 hibernate3整合
- Struts2+Spring3+Hibernate3整合
- struts2+spring3+hibernate4整合
- Struts2+spring3+mybatis3整合
- spring3 struts2 整合
- struts2与spring3整合
- spring3+Hibernate4+struts2整合
- Spring3整合Struts2
- Struts2+Hibernate3+Spring3 整合
- spring3整合struts2
- Struts2+Spring3+Hibernate3整合
- spring3 struts2 hibernate3整合
- spring3.1整合Struts2.3,spring3.1整合hibernate4.1与3.3
- myBatis3,spring3,struts2.2整合
- spring3.1+struts2+hibernate4整合
- Struts2.3 + Spring3.2 整合
- struts2+spring3整合配置文件实例
- ffmpeg解码实例
- 基于弹性计算平台——构建高可用、可扩展的应用
- ASP.NET读取ASP设置的Cookie
- 让javascript跑得更快
- #pragma once #ifndef
- struts2.3.3整合spring3.3.1
- VMware虚拟机中双网卡连接双物理网卡的实现
- ipv6 socket
- hbase shell 简单使用
- Server Side Include( SSI )学习
- 图片立体边框效果
- Android控件之ZoomControls缩放控件
- linux之cut用法
- 创建触发器,报索引中丢失IN或OUT参数::1