Spring Integrated Struts

Source: Internet
Author: User

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

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.