"Web Development Learning note" STRUCTS2 Action learning Note (ii)

Source: Internet
Author: User

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

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.