Struts 2 Action class contain one execute() method. Whenever, Action class object create the container, at the same time the time execute() will be executed and it returns result in String type.
package com.splesson; public class ActionClass { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public String execute() { return "success"; } }
package com.splesson; import com.opensymphony.xwork2.Action; public class SPLessons implements Action { public static final String SUCCESS="success"; public static final String ERROR="error"; public static final String LOGIN="login"; public static final String INPUT="input"; public static final String NONE="none"; public String execute() { return "success"; } }
Action Class is provided from Action Support class. If one extened the ActionSupport class then it will be provided more interfaces like Action, ValidationAware,Validateable, TextProvider, LocaleProvider and Serializable. AcctionSupport class contain com.opensymphony.xwork2.ActionSupport package.
package com.splesson; import com.opensymphony.xwork2.ActionSupport; public class SPLessons extends ActionSupport { public String execute() { return "SUCCESS"; } }