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