What is the difference between returning a SUCCESS
and Action.SUCCESS
for your execute method in struts 2? I know about returning a SUCCESS
string, but I couldn't figure the Action.SUCCESS
one?
Take a look on source code of Action
:
public static final String SUCCESS = "success";
I think that this line explains better than any words that Action.SUCCESS
and string constant "success"
are the same.
Action.SUCCESS
is a String
constant defined in the Action
interface. see here
It will be available in all your Action classes that implement this interface. Your own action classes inherit this constant.
So there is practically no difference between Action.SUCCESS
and SUCCESS
inside a class that implements Action
.
They are the same if point to the same constant in Action
class. But to use the first case required either the action class to implement the Action
interface better with extending the ActionSupport
which implements the Action
interface or use static imports. The second case is the usual way to access static resources.
They are both string mapped to "success" string.
public interface Action {
/**
* The action execution was successful. Show result
* view to the end user.
*/
public static final String SUCCESS = "success";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.