Struts 2 Action
In struts 2, action class is POJO (Plain Old Java Object).
POJO means you are not forced to implement any interface or extend any class.
Generally, execute method should be specified that represents the business logic. The simple action class may look like:Welcome.java
A convenient approach is to implement the com.opensymphony.xwork2.Action interface that defines 5 constants and one execute method.
5 Constants of Action Interface
Action interface provides 5 constants that can be returned form the action class. They are:
Let's see what values are assigned to these constants:
Method of Action Interface
Action interface contains only one method execute that should be implemented overridden by the action class even if you are not forced.
Example of Struts Action that implements Action interface
If we implement the Action interface, we can directly use the constants instead of values.Welcome.java
It is a convenient class that implements many interfaces such as Action, Validateable, ValidationAware, TextProvider, LocaleProvider and Serializable . So it is mostly used instead of Action.
Example of Struts Action that extends ActionSupport class
Let's see the example of Action class that extends the ActionSupport class.Welcome.java