Spring整合Struts2

本文详细介绍了如何将Struts2与Spring框架进行整合,包括配置Struts2主配置文件、设置web.xml中的Struts2核心过滤器,并通过引入特定的jar包实现两者的集成。文中还特别强调了如何利用Spring进行依赖注入,确保Action对象能够正确创建并使用。

1、配置Struts2主配置文件

2、配置struts2核心过滤器到web.xml


struts2与Spring整合

1、导包(struts2-spring-plugin-2.3.24.jar)


2、需要配置常量

### if specified, the default object factory can be overridden here
### Note: short-hand notation is supported in some cases, such as "spring"
###       Alternatively, you can provide a com.opensymphony.xwork2.ObjectFactory subclass name here
# struts.objectFactory = spring

### specifies the autoWiring logic when using the SpringObjectFactory.
### valid values are: name, type, auto, and constructor (name is the default)
struts.objectFactory.spring.autoWire = name


<!--   # struts.objectFactory = spring   将aciton的创建交给Spring容器
             struts.objectFactory.spring.autoWire = name spring负责装配Action依赖属性
     -->


     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值