Struts 2 Action
In swaggers 2, activity class is POJO (Plain Old Java Object).
POJO implies you are not compelled to actualize any interface or broaden any class.
Generally, execute technique ought to be indicated that speaks to the business rationale. The straightforward activity class may look like:Welcome.java
A helpful methodology is to actualize 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 demonstrates that activity execution is effective and a triumph result ought to be appeared to the user.
- ERROR demonstrates that activity execution is fizzled and a blunder result ought to be appeared to the user.
- LOGIN demonstrates that client isn't signed in and a login result ought to be appeared to the user.
- INPUT demonstrates that approval is fizzled and an information result ought to be appeared to the client again.
- NONE demonstrates 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 actualized superseded by the activity class regardless of whether you are not forced.
Example of Struts Action that actualizes Action interface
If we actualize the Action interface, we can legitimately utilize the constants rather than values.Welcome.java
It is an advantageous class that actualizes 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