Action Learning Note 2-Discussion on action methodThe Execute method is not necessarily executed when the action is executed, and you can use method= to specify which method to execute when you configure the action in the configuration file.
Can also be specified dynamically in the URL address (dynamic method call DMI) (recommended)
Method One
<struts > <constant name= "Struts.devmode" value= "true"/> <package name= "user" extends= "Struts-default" Namespac e= "/user" >//method one <action name= "UserAdd" class= "Com.struts2.user.action.UserAction" method= "Add" > <result>/user_add_success.jsp</result> </action>//Method two <action name= "user" Clas s= "Com.struts2.user.action.UserAction" > <result>/user_add_success.jsp</result> </actio n> </package> </struts><span style= "font-family:arial, Helvetica, Sans-serif;" > </span>
Package com.bjsxt.struts2.user.action; Import Com.opensymphony.xwork2.ActionSupport; public class Useraction extends Actionsupport {public String Add () {return SUCCESS;} }
Calling method: Http://localhost:8080/Struts2_0500_ActionMethod//user/userAdd
Method TwoThe former produces too much action, so it is not recommended to use
Call Method:Http://localhost:8080/Struts2_0500_ActionMethod/user/user!add
DMI dynamic method invocation;
The second method of common use