Struts2 Learning Path (iii)--action method invocation

Source: Internet
Author: User

As mentioned in the previous article (http://www.cnblogs.com/denisechen/p/4644275.html), the Execute method is not necessarily executed when the action is executed. So how do you decide which method to invoke? There are three ways of doing this:

1. Specify methods using the Method property

This approach causes a lot of action to be created.

1 <Actionname= "Order"class= "Com.action.Order"Method= "Add">2     <resultname= "Add">/success.jsp</result>3 </Action>

2. Dynamic method Invocation (DMI)

There is no special action, and an action can contain multiple result.

1 <Actionname= "Order"class= "Com.action.Order"> 2     <resultname= "Add">/add.jsp</result> 3     <resultname= "Delete">/delete.jsp</result> 4 </Action> 

Using the! Access method, the following is an example of a call in a JSP file:

1 <  href= "order!add.action">   Add Order  </a>  2<href= "order!delete.action"> Delete Order </a>

3. Using wildcard characters (recommended)

Using the {} brackets to add numbers, you can have multiple wildcard characters, which are matched sequentially.

1 <Actionname= "order*"class= "Com.action.Order"Method= "{1}">2             <resultname= "{1}">/order{1}.jsp</result>3 </Action>

When called in a JSP:

1 <  href= "orderadd.action">  Add Order  </a>  2<href= "orderdelete.action"> Delete Order </ a >

Struts2 Learning Path (iii)--action method invocation

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.