Spring learning drip, spring in Action notes (iii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.