一、spring管理struts配置
1、增加插件,修改
struts-config.xml
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
2、在web.xml中配置spring
增加插件管理
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext.xml
</param-value>
</context-param>
增加监听器
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3、将DAO交由spring管理,之后通过IOC方式注入DAO对象
在applicationContext.xml添加如下
<bean name='/person' class="org.ssh.struts.PersonAction">
<property name="persondao">
<ref bean="persondao"/>
</property>
</bean>
附
struts-config.xml
<action-mappings >
<action
attribute="personForm"
input="/form/person.jsp"
name="personForm"
parameter="status"
path="/person"
scope="request"
type="org.ssh.struts.PersonAction" />
</action-mappings>