1. Example: not integrated by spring
Configuration file for Struts.xml
<constantname= "Struts.enable.DynamicMethodInvocation"value= "true" /> <constantname= "Struts.configuration.xml.reload"value= "true"/> <!--configuration extension. do - <constantname= "Struts.action.extension"value= "Do"></constant> < Packagename= "Default"namespace="/"extends= "Struts-default"><!--{1} represents the first * {2} for the second *--<Actionname="*_*" class= "Com.test.controller. {1} Action "Method= "{2}"> <resultname= "Success">index.jsp</result> </Action> </ Package>
Note This configuration, full class name. Struts finds this class through the actionmaping configuration
Test: Call the Dogetstudentinfo () method of the Studentaction class under the Com.test.controller package
The way the foreground invokes this action is
Note: Here is the first letter of the student, which is the first half of the studentaction
2. Example: After spring integration
Configuration file for Struts.xml
<Struts><!--create an instance of an object from spring instead of struts - <constantname= "Struts.objectfactory"value= "Spring" /> <!--configuring spring Automatic assembly Instances - <constantname= "Struts.objectFactory.spring.autoWire"value= "true"></constant> <constantname= "Struts.enable.DynamicMethodInvocation"value= "true" /> <constantname= "Struts.configuration.xml.reload"value= "true"/> <!--configuration extension. do - <constantname= "Struts.action.extension"value= "Do"></constant> < Packagename= "Default"namespace="/"extends= "Struts-default"> <Actionname="*_*"class= "{1}action"Method= "{2}"> <resultname= "Success">index.jsp</result> </Action> </ Package> <!--<include file= "Example.xml"/> -</Struts>
Note This place: it has become the spring auto-created Beanid, where the Beanid created automatically is generated by annotations.
The Beanid generated by this annotation is studentaction, Note that the first letter here is lowercase, which is converted when spring creates an instance.
Testing: Front desk access
Error: Reason, time should be called when the action instance name is already studenaction instead of studentaction
That's right.
The spring configuration file does not have a special setup configuration, and the spring and struts are now integrated
Spring Integrated Struts