Struts 2 Action
In Struts 2, activity class is POJO (Plain Old Java Object).
POJO means you are not compelled to implement any interface or broaden any class.
Generally, execute method ought to be indicated that speaks to the business rationale. The simple activity class may look like:Welcome.java
A helpful methodology is to implement the com.opensymphony.xwork2.Action interface that characterizes 5 constants and one execute method.
5 Constants of Action Interface
Action interface gives 5 constants that can be returned structure the activity class. They are:
- SUCCESS indicates that activity execution is effective and a triumph result ought to be appeared to the user.
- ERROR indicates that activity execution is fizzled and a blunder result ought to be appeared to the user.
- LOGIN indicates that client isn't signed in and a login result ought to be appeared to the user.
- INPUT indicates that approval is fizzled and an information result ought to be appeared to the client again.
- NONE indicates that activity execution is effective however no outcome ought to be appeared to the user.
Let's see what esteems are alloted to these constants:
Method of Action Interface
Action interface contains just a single strategy execute that ought to be implement d superseded by the activity class regardless of whether you are not forced.
Example of Struts Action that implement s Action interface
If we implement the Action interface, we can legitimately utilize the constants rather than values.Welcome.java
It is an advantageous class that implement s numerous interfaces, for example, Action, Validateable, ValidationAware, TextProvider, LocaleProvider and Serializable . So it is generally utilized rather than Action.
Example of Struts Action that expands ActionSupport class
Let's see the case of Action class that expands the ActionSupport class.Welcome.java