How to integrate an old Struts application with Spring 3.x -
i wondering how , prefered way of integrating struts 1.x application spring 3.x can benefit ioc stuff.
use contextloaderplugin , set struts controller processorclass "autowiringrequestprocessor" (in struts-config.xml):
<controller> <set-property property="processorclass" value="org.springframework.web.struts.autowiringrequestprocessor" /> </controller> <plug-in classname="org.springframework.web.struts.contextloaderplugin"> <set-property property="contextconfiglocation" value="/web-inf/config/action-servlet.xml"/> </plug-in>
action-servlet.xml has empty beans context file:
<beans></beans>
add following init parameter actionservlet in web.xml:
<init-param> <param-name>autowire</param-name> <param-value>byname</param-value> </init-param>
just write regular struts actions, , add annotation "@component" every action spring discover actions , creates bean out of it. "autowiringrequestprocessor" find right bean matches action class defined in struts-config.xml.
it's possible have other beans injected action class @autowired on setter(s).
Comments
Post a Comment