spring struts2整合

把struts2的action交给spring管理

一、导入相应jar包

导入与spring有关的基本jar包,和与struts2有关的基本jar包

还需要导入

struts2-spring整合jar包

二、配置web.xml

除了配置struts2的filter外还需要配置

1.监听器

2.将spring的配置文件导入web中

三、编写action

四、配置spring的配置文件bean1.xml

因为要将action交给spring管理

五、配置struts2的配置文件struts.xml

如果action的class填写类的全路径会是action在struts2中创建一次,在spring中创建一次,因此导入了struts2-spring整合包class填写spring配置文件bean的id值。

原文地址:https://www.cnblogs.com/lolybj/p/6384799.html