Action Learning Note 2-about action method discussionaction does not have to run the Execute method, you can configure the action in the configuration file with method= to specify which method to run
Can also be specified dynamically in the URL address (dynamic method invoke 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;
Another method is often used
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
"Web Development Learning note" STRUCTS2 Action learning Note (two)