Tenth chapter. Using other Web Frames
Spring provides two ways to integrate with Struts
1 Let your Action inherit Org.springframework.web.struts.ActionSupport
2 delegate the request to the Struts action P312, which is managed as a Spring Bean
42. In order for Struts to access a spring-managed Bean, you must register a contextloaderplugin in Struts-config.xml that knows the spring context, using the Webapplicationcontext : (P312)
<plug-in classname= "Org.springframework.web.struts.ContextLoaderPlugIn" >
<set-propertyset-property= "Contextconfiglocation" value= "/web-inf/training-
servlet.xml,/web-inf/..." >
</plugin-in>
<plug-in
classname= "Org.springframework.web.struts.ContextLoaderPlugIn" >
<set-
property= "contextconfiglocation" value= "/web-inf/training-servlet.xml,/web-INF/
..."
</plugin-in>
Actionsupport overloaded The Setservlet () method to get the bean in the form of a call to Actionsupport Getwebapplicationcontext (). Getbean () (P313)
44. Inheriting the actionsupport provided by spring allows struts to be tightly coupled with spring, and the Action is also responsible for locating the Bean, which violates the IOC principle (P313)
45. Use the delegate action:struts-config.xml each path specifies the type as org.springframework.web.struts.DelegatingActionProxy, and the actual action Instances are managed by spring, where all Action instances are configured in the spring context file and mapped between them with Path<->name, which is not pretty (P315)
46. Use request delegate, only configure Delegatingrequestprocess or Delegatingtilesrequestprocessor as controller in Struts-config.xml, the remaining configuration is unchanged, such as < Action path= "/listcourses" type= "com.unmi.MyCoursesAction"/> In fact, the type attribute is ignored by the configured controller, so you can omit the type attribute. The real action is also configured by spring and also by Path--name. The practice is that you do not need to specify Org.springframework.web.struts.DelegatingActionProxy for each <action .../>. (P315)